문법 비교2 [Java/Python] 문법 비교 정리 #7 자료구조 - HashMap(Dictionary) Python에서 이야기하는 Dictionary 자료 구조는 타 언어에서는 HashMap이라는 명칭으로 사용되나 두개의 명칭 모두 동일한 자료 구조를 가지고 있습니다. 공통적인 특징으로는 key, value의 한쌍의 형태를 띄고 있으며 중복되는 key를 허용하지 않습니다. Java에서의 HashMap // HashMap 선언 Map map = new HashMap(); map.put("name", "a"); map.put("age", 100); map.put("name", "b"); // 처음 대임된 a -> b로 변경 됩니다. // 결과 // key : name, value : b // key : age, value : 100 for (Object o : map.keySet()) { System.out... 2022. 11. 9. [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 다음