Java - Set (HashSet, TreeSet)
Set : 중복을 허용하지 않는다. 순서 관리가 되지 않는다. Set은 추상인터페이스로 직접생성이 불가능 소스 public static void main(String[] args) { // 데이터의 정렬이 필요치 않을 경우 //Set set = new HashSet(); // 데이터 정렬이 필요할 경우 Set set = new TreeSet(); // add가 됬을경우 true System.out.println(set.add("one")); System.out.println(set.add("two")); System.out.println(set.add("three")); System.out.println("크기 : " + set.size()); // 같은값을 허용하지 않기 때문에 false 반환 Syst..
개발/Java
2018. 9. 28. 16:25