본문 바로가기

Java14

[Java] Arrays.sort 활용 입력되는 값을 정렬해야 할 필요가 있을때 Arrays.sort 를 활용한다. import java.util.Arrays; class Solution { public int solution(int n, int[] lost, int[] reserve) { Arrays.sort(lost); Arrays.sort(reserve); int answer = 0; return answer; } } 관련 문제 : 프로그래머스 체육복 2022. 10. 14.
[Java] CollectionUtils.isEmpty의 장점 일반 컬렉션의 isEmpty() 메서드를 사용할때 추가로 null 체크를 해주어야 하는데 CollectionUtils의 isEmpty 메서드는 null 체크를 해준다. ref : https://stackoverflow.com/questions/12721076/best-practice-to-validate-null-and-empty-collection-in-java 2022. 7. 28.
[Java] 엑셀 시트 이름 개선하기 WorkbookUtil.createSafeSheetName("대상시트이름") 입력 불가능 한 특수문자를 제거하거나, 문자열 길이가 초과하는걸 방지해준다. ref : https://poi.apache.org/apidocs/dev/org/apache/poi/ss/util/WorkbookUtil.html 2022. 6. 8.
[Java] 인터페이스 vs 추상클래스 * 인터페이스 - 관련 없는 클래스끼리 인터페이스를 구성할때 ex) Serializable - 기능지향 (객체가 가져야 할 기능 정의) - 상수, 메서드 스텁 (본문 없는 메서드) * 추상클래스 - 밀접하게 관련된 여러 클래스 간에 코드를 공유하려 할때 - 객체지향 (객체가 가져야하는 기본 데이터 및 수행할 수 있어야 하는 기능) - 상수, 멤버, 메서드 스텁, 정의된 메서드 ref : https://stackoverflow.com/questions/1913098/what-is-the-difference-between-an-interface-and-abstract-class 2022. 4. 4.