HashSet Class



















public static void main(String[] args){
String[] tropical = new String[]{"사과", "배", "참외", "포도","사과", "바나나", "키위", "포도","귤", "바나나", "오렌지","포도"}; // Tropical 과일 12개 넣기
System.out.println("map size : "+getTropical(tropical));
}

public static int getTropical(String[] tropical){
if(tropical==null) return 0;        
if(tropical.length==1) return 1;  
HashSet<String> hash= new HashSet<String>();

for(String tmp : tropical){    
hash.add(tmp);      
}
printTropical(hash);  
return hash.size();    
}

public static void printTropical(HashSet<String> hash){
for(String tmp :  hash){                            
System.out.print(tmp+" / ");                    
}
System.out.println();
}
------------------------------------------------------------------------
result :
배 / 키위 / 사과 / 참외 / 포도 / 귤 / 바나나 / 오렌지 /
map size : 8

Popular posts from this blog

youtube download

com.gpki.secureweb.GPKISecureWEBException: ErrCode=1507,ErrMsg=[GPKI_CMS_ProcessEnvelopedData] 해당 인증서로는 데이터를 풀 수 없습니다.

rexpert 공식필드(javascript) 점검일 주기 계산