Notice
Recent Posts
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- MySQL
- 버튼
- 자바스크립트
- jsp
- 필터체인
- 폼태그
- Eclipse
- 깃허브
- 제이쿼리
- SESSION
- 스프링
- 오라클
- 면접
- java
- jquery
- 설정
- 알고리즘
- jstl
- springboot
- 깃허브 간단요약
- jsp 내부객체
- Oracle
- 설치
- 마이바티스
- 이클립스
- 자바
- Spring
- 셋업
- EL태그
- html
Archives
- Today
- Total
은은하게 코드 뿌시기
컬렉션프레임웍(Collections Framework) - 큐(Queue) 본문
728x90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
//큐
/*
* 큐
* LinkedList 로 생성
*
* rear >>> data >>> front
* add : rear로 값 추가
* peek : front 데이터 확인
* poll - front데이터 삭제하고 확인
*/
Queue<Integer> que = new LinkedList<Integer>();
for (int i= 1;i<=10;i++) {
que.add(i);
}
System.out.println("=============que");
System.out.println("que" + que.toString());
System.out.println("que peek : " + que.peek());
que.poll();
System.out.println("poll " + que.toString());
|
cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
class code1_que {
public static void main(String[] args) {
System.out.println("Queue test");
//FIFO
Queue<String> que = new LinkedList<String>();
// 값 집어넣기
que.add("item 1 push");
que.add("item 2 push");
System.out.println(que);
System.out.println(que.offer("item 3 push"));
System.out.println(que);
// 나올 값 확인하기
System.out.println(que.peek());
// 값 빼기
que.poll();
System.out.println(que);
}
}
|
cs |
728x90
'자바 > Collections Framework' 카테고리의 다른 글
컬렉션프레임웍(Collections Framework) - HashMap (0) | 2022.10.02 |
---|---|
컬렉션프레임웍(Collections Framework) - TreeSet (0) | 2022.10.02 |
컬렉션프레임웍(Collections Framework) - 스택(stack) (0) | 2022.10.02 |
컬렉션프레임웍(Collections Framework) - ArrayList (0) | 2022.10.02 |
컬렉션프레임웍(Collections Framework) - HashSet (0) | 2022.10.02 |
Comments