### Stack - LIFO - First in First Out
Deque<Integer> stack = new ArrayDeque<>();
push(element) - insert element on the top of the stack
pop() - remove topmost element
peek() - get topmost element
### Queue - FIFO - First in First out
Deque<Integer> queue = new ArrayDeque<>();
offer(element) - add element at the start of the Queue
poll() - remove first element of the Queue
peek() - get first element of the Queue
### PriorityQueue
PriorityQueue<String> fruits = new PriorityQueue<>();
- нарежда ги по азбучен ред или по големина
while (!queue.isEmpty()){
Integer element = queue.poll();
System.out.println(element);
} - принтира всичките елементи (важи и за опашките)
******** important *********
add() – throws exception if queue is full
offer()– returns false if a queue is full
remove()-throws exception if queue is empty
poll()-returns null if queue is empty
-
Notifications
You must be signed in to change notification settings - Fork 0
All tasks i have done from the SoftUni course - Java Advanced - September 2024
detelinka/3-Java-Advanced
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
All tasks i have done from the SoftUni course - Java Advanced - September 2024
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published