queue_in_java

 package com.company;

import java.util.LinkedList;
import java.util.Queue;
public class queu_in_java
{
public static void main(String[] args)
{
Queue<Integer> q=new LinkedList<>();
// adds elements {0, 1, 2, 3, 4} to
// the que
for(int i=0; i<5; i++)
q.add(i);
// display content of the queue
System.out.println("Element of the queu "+q);
// remove the head of the queue
int removablle=q.remove();
System.out.println("removed element is -"+removablle);
System.out.println(q);
//to view head of the queue
int head=q.peek();
System.out.println("head of the queue-"+head);
int size=q.size();
System.out.println("size of the queue - "+size);

}
}

Comments

Popular posts from this blog

priority_queue

css in phone