intreface Comparable {
int compareTo (T o)
}
Comparable intreface : java.lang안에 존재함. Boolean 제외한 String, Date, File class가 오름차순 정렬됨.
지원되지않는 class의 instance를 TreeSet에 넣으면, exception error가 발생함
java.lang에 존재하는것이므로 따로 import 필요없음
interface Comparator {
int compare (T o1, T o2);
boolean equals (Object obj);
}
Comparator interface : java.util에 존재함.
import java.util.Comparator;
java.util을 임포트 해야 사용할 수 있음.
'프로그래밍 > JAVA' 카테고리의 다른 글
[JAVA] for 구문에서 i cannot be resolved to a variable 에러 (0) | 2021.04.08 |
---|---|
int (integer) 와 float 자료형은 어떻게 다른가? JAVA에서... (0) | 2021.04.07 |
[JAVA] the selection cannot be launched and there are no recent launches (0) | 2021.03.20 |
[JAVA] Syntax error on token "Class", class expected 에러 (0) | 2021.03.20 |
[JAVA] ubuntu용 Spring tool suite 4 에 legacy Spring 설치하기 (0) | 2021.03.19 |