HashSet

응용 SoftWare/JAVA 2016. 12. 14. 17:01

import java.util.HashSet;

import java.util.Iterator;


public class HashSetTest {

Double data[] = {23.2, 25.6, 89.6, 56.7, 23.2, 25.6, 89.6, 56.7};

public HashSetTest() {

//중복을 허용하지 않음

HashSet<Double> hs = new HashSet<Double>();

for(int i=0; i<data.length; i++){

hs.add(data[i]);

}

//출력

Iterator<Double> ii = hs.iterator();

while(ii.hasNext()){ //객체가 있는지 확인

System.out.println(ii.next());

}

}


public static void main(String[] args) {

new HashSetTest();


}


}



'응용 SoftWare > JAVA' 카테고리의 다른 글

HashMap  (0) 2016.12.14
TreeSet  (0) 2016.12.14
LinkedList  (0) 2016.12.14
Stack  (0) 2016.12.14
Properties  (0) 2016.12.14
Posted by Hyun CHO
,