JAVA2 JAVA-Queue Queue는 FIFO 방식이다. (FirstinFirstOut)방식 -> 먼저들어온것이 먼저나가다. Queue 선언 Queue q = new LinkedList(); Queue i = new LinkedList(); //integer타입 Queue str = new LinkedList(); //string타입 queue를 선언할때는 LinkedList를 이용한다. Queue 값 추가 -> add()메서드 Queue 값 삭제 -> poll(),remove() 메서드 가장 앞쪽에 있는 값부터 제거 Queue 값 출력 -> peek() 메서드 queue에서 첫번째로 들어간 값을 출력하고 싶다면 peek()메서드 사용 2022. 5. 22. JAVA - HashSet HashSet ? HashSet은 중복을 허락하지 않고 정렬이 필요없는 경우에 쓰인다. 같은 자료를 보관할 수 없다. null요소를 허용한다. 빠른검색을 할 수 있어 많은 자료를 관리해야한다면 HashSet을 사용하면 좋다. HashSet 클래스 -변수선언, add,remove HashSet set = new HashSet(); HashSet set = nw HashSet(); HashSet에 맞는 데이터 추가 set.add(3); set.add(4); HashSet 값 삭제 set.remove(3); //3 값만 삭제 set.clear(); //전부 삭제 HashSet 크기 HashSet의 size() 메서드 이용 Syste.out.println(set.size()); HashSet 검색 값이 존재한다.. 2022. 5. 12. 이전 1 다음