일반 java.util.Queue

황제낙엽 2022.04.06 11:35 조회 수 : 5381

sitelink1 https://blog.naver.com/rhrudwnszoq/222626952478 
sitelink2 https://docs.oracle.com/javase/8/docs/ap...Queue.html 
sitelink3  
sitelink4  
sitelink5  
sitelink6  

import java.util.LinkedList;

import java.util.Queue;

 

ublic class CacheEngine {

        public static void main(String[] args) { 

            Queue<Integer> queue = new LinkedList<>(); 

            for (int i = 1; i <= 10 ; i++) { 

                queue.offer (i); // input 

                System.out.println("Queue :" + queue); 

            } 

            // 1. 무한 루프 돌리기 

            // poll() 가장 첫번째로 입력한 데이터부터 반환 

            while (!queue.isEmpty()) { //비어있지 않으면 안일어난거임 

                System.out.println("POLL:" + queue.poll()); 

                System.out.println("QUEUE: " + queue); 

                } 

            }

        }

}

 

 

 

[Method]

 

boolean add(E e) - 넣기

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.

 

E remove() - 꺼내기

Retrieves and removes the head of this queue.

 

E element() - 확인하기

Retrieves, but does not remove, the head of this queue.

 

boolean offer(E e) - 넣기, 넣을 공간이 부족하면 false 반환 

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.

 

E poll() - 꺼내기, 꺼낼 대상이 없으면 null 반환

Retrieves and removes the head of this queue, or returns null if this queue is empty.

 

E peek() - 확인하기. 확인할 데이터가 없으면 null 반환 

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.

 

 

 

image.png

 

번호 제목 글쓴이 날짜 조회 수
351 java.lang.IllegalArgumentException 황제낙엽 2010.01.18 130513
350 Using RSS in JSP pages (Informa Project) 황제낙엽 2006.01.10 37829
349 JSP 파일에서 getOutputStream() has already been called for this response 에러 황제낙엽 2013.04.24 11479
348 한글 파일명 깨짐으로 살펴본 다국어 처리 문제 (UTF-8) 황제낙엽 2012.03.22 10121
347 세션의 timeout 설정 >> HttpSession.setMaxInactiveInterval() 황제낙엽 2019.07.03 8311
346 [JSON기초04] 자바 JSON 데이터에서 KEY 값 알아오기 (TIP) 황제낙엽 2017.01.18 6641
» java.util.Queue file 황제낙엽 2022.04.06 5381
344 쓰레드(Thread)를 중간에 종료시키는 방법 황제낙엽 2017.03.15 5127
343 Java 실행 옵션들 황제낙엽 2017.08.23 3367
342 일본어 전각 반각 변환 예제 소스 .첫번째 file 황제낙엽 2007.01.10 3070
341 byte배열에 대한 CRC 를 계산하는 메서드 (java.util.zip.CRC32) 황제낙엽 2010.03.14 2166
340 UTF형태 파일에서 BOM 제거하기 황제낙엽 2008.06.16 1938
339 File.delete() 와 File.deleteOnExit() 황제낙엽 2019.03.24 1887
338 [대용량 파일 업로드] multipart form parser - http file upload, database 저장 java class 연재2 file 황제낙엽 2009.06.19 1831
337 싱글톤 방식의 테스트용 Temporary Data Access Object 황제낙엽 2017.01.12 1603
336 servlet 에서의 json 한글처리 황제낙엽 2013.04.23 1519
335 날짜, 시간 문자열 값으로 Date 오브젝트로 만들기 >> SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.US) 황제낙엽 2017.10.31 1516
334 J2EE object-caching frameworks (ObjectCache) 황제낙엽 2007.11.02 1495
333 [대용량 파일 업로드] multipart form parser - http file upload 기능 java class 연재1 file 황제낙엽 2009.06.19 1436
332 JavaMail - 네이버 메일 수신하기(POP3) 황제낙엽 2018.08.20 1413