forked from vishallovecode/JavaWithDsa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuequeusingarraylist.java
More file actions
29 lines (24 loc) · 706 Bytes
/
Quequeusingarraylist.java
File metadata and controls
29 lines (24 loc) · 706 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
26
27
28
29
import java.util.ArrayList;
public class QuequeWithArrayList {
ArrayList<Integer> al = new ArrayList<>();
// adding the element into the queque ??
public void enque (int data) {
al.add(data);
}
public int dequeue () {
// remove the element which is the firsr element inserted in the arraylist / queque
// is Queque is empty or not
if(isEmpty()) {
return -1;
}
int rear = al.get(al.size()-1);
al.remove(al.size()-1);
return rear;
}
// is full condition not needed
public boolean isEmpty () {
return al.size()==0;
}
public static void main(String[] args) {
}
}