[ Java: Set 인터페이스 / HashSet, TreeSet ]


[ Java: Set 인터페이스 / HashSet, TreeSet ]

주민등록번호, 회원 아이디와 같이 중복을 허용하지 않고, 순서가 상관없는 경우 Set 인터페이스를 사용합니다. Set 인터페이스의 대표 클래스로 HashSet과 TreeSet이 있습니다. HashSet 클래스 HashSet: 집합 자료 구조 구현, 중복을 허용하지 않음 겁먹지 말고 위 의미를 쉽게 알아보도록 아래 예시를 통해 살펴보겠습니다. package collection.hashset; import java.util.HashSet; public class HashSetTest { public static void main(String[] args) { HashSet<String> hashSet = new HashSet<String>(); hashSet.add(new String("정재승")); hashSet.add(new String("김영민")); hashSet.add(new String("김명선")); hashSet.add(new String("김난도")); hashSet.a...


#HashSet #java #Set #TreeSet #자바

원문링크 : [ Java: Set 인터페이스 / HashSet, TreeSet ]