Set hset = new HashSet();
Set tset = 새로운 TreeSet();
Set 설정 lset = new LinkedHashSet();
Set hset = new HashSet();
hset.add(새 문자열("1"));
hset.add(새 문자열("2"));
3)이터레이터 iterator()hset.remove("1");
Set4)Int size()hset = new HashSet ();
이터레이터 반복자 = hset.iterator();
while(iterator.hasNext(){
문자열 요소 = (문자열) iterator.next();
}
System.out.println(hset.size());
Set 삽입하려는 객체 유형을 제한 할 수 있습니다< 문자열> 세트 = 새로운 HashSet< 문자열> ();이 문은 String 개체만 허용합니다. 장점은 캐스트가없는 < > / span :
for (String Object : set) {
// 뭔가를
}
< / pre>References :
Java 컬렉션 : Set
Javadoc: 인터페이스 설정
Please disable your ad blocker and refresh the window to use this website.