ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [Java] Google Sets 클래스를 이용한 집합 구하기
    Programming/Java 2020. 5. 12. 10:48

    HashSet<String> savedList = getSavedList();
    HashSet<String> currentList = getCurrentList();
    
    //대칭차
    SetView<String> setView = Sets.symmetricDifference(savedList, currentList);
    
    //교집합
    Set<String> retainList = Sets.intersection(currentList, setView);
    
    //차집합
    Set<String> difference = Sets.difference(currentList, setView);
    
    //합집합
    Set<String> union = Sets.union(currentList, setView);
    
    
    
    
    for(String item : union) {
    	System.out.println(item);
    }
    반응형

    'Programming > Java' 카테고리의 다른 글

    [Java] Comparator를 활용한 Map 정렬  (0) 2020.05.12
Designed by Tistory.