-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue1.java
More file actions
25 lines (24 loc) · 754 Bytes
/
Copy pathqueue1.java
File metadata and controls
25 lines (24 loc) · 754 Bytes
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
import java.util.*;
import java.util.LinkedList;
public class queue1{
public static void main(String[] args) {
Queue<Integer> q=new LinkedList<>();
System.out.println(q.isEmpty());
q.add(1);//add =push
System.out.println(q.isEmpty());
q.add(2);
q.add(3);
q.add(4);
System.out.println(q.size());//get size
System.out.println(q);
q.remove();//remove=pop
System.out.println(q);
q.poll();//poll=remove=pop
System.out.println(q);
System.out.println(q.element());//element=peek
System.out.println(q.size());
q.add(5);
System.out.println(q.poll());
System.out.println(q);
}
}