[Java/Python] 문법 비교 정리 #6 자료구조 - Set
Java에서의 Set Set a = new HashSet(Arrays.asList(1, 3, 2, 4, 8, 9, 0)); Set b = new HashSet(Arrays.asList(1, 3, 7, 5, 4, 0, 7, 5)); // 합집합 Set union = new HashSet(a); union.addAll(b); System.out.println(union); // 0, 1, 2, 3, 4, 5, 7, 8, 9 // 교집합 Set intersection = new HashSet(a); intersection.retainAll(b); System.out.println(intersection); // 0, 1, 3, 4 // 차집합 Set difference = new HashSet(a); diff..
2022. 11. 8.