Skip to content

detelinka/3-Java-Advanced

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

CHEAT SHEET

Stacks & Queues / Стекове и Опашки

### 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
  

Multidimensional Arrays / Многомерни масиви - матрици

About

All tasks i have done from the SoftUni course - Java Advanced - September 2024

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published