ADD2 [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. [Java/Python] 문법 비교 정리 #5 자료구조 - Queue, Stack Java에서의 Queue, Stack 1. Queue // queue 선언 방법 1 Queue queueLinkedList = new LinkedList(); queueLinkedList.add(1); queueLinkedList.add(2); queueLinkedList.add(5); queueLinkedList.add(4); queueLinkedList.add(3); // FIFO 유지 : queueLinkedList -> 1,2,5,4,3 //------------------------------------------------- // queue 선언 방법 2 Queue priorityQueue = new PriorityQueue(); priorityQueue.add(1); priorityQueue.. 2022. 11. 7. 이전 1 다음