Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

queue in java

queues, //add, remove, peek , size()
    Queue<Integer> q = new LinkedList<>();
	- Unlike stacks, a queue is open at both its ends. (one end enqueue & one end remove data, dequeue) FIFO
	- enqueue() − add (store) an item to the queue. 
	- dequeue() − remove (access) an item from the queue.
	- peek() − Gets the element at the front of the queue without removing it.
	- isfull() − Checks if the queue is full.
	- isempty() − Checks if the queue is empty.
      
      Queue<Integer> queue = new LinkedList<Integer>();
        queue.add(10);
        queue.add(20);
        int a = queue.remove();
        int peek = queue.peek();
        System.out.println(queue + " " + a); //[20] 10
 
PREVIOUS NEXT
Tagged: #queue #java
ADD COMMENT
Topic
Name
6+9 =