import java.util.*;
public class Queue {
    int a[];
    int rear=-1, front =-1;
    Queue()
    {
        a=new int [5];
    }
    Queue(int n)
    {
a=new int[n];
    }
    void insert(int n)
    {
        if(rear==a.length-1)
            System.out.println("Queue Full");
        else
            a[++rear]=n;
    }
    int delete() throws Exception
    {
        if(rear==front)
            throw new Exception("Queue is Empty");
        else
            return a[++front];
    }
}
class QueueExp
{
  public static void main(String args[]) throws Exception
  {
      Queue obj=new Queue();
      Scanner src=new Scanner(System.in);
      System.out.println("Enter the Elements in the Queue:- ");
      for(int i=0;i<5;i++)
          obj.insert(src.nextInt());
      System.out.println("Elements which you want to delete? ");
      int x=src.nextInt();
      System.out.println("Deleted Elements: ");
      for(int i=0;i<x;i++)
          System.out.println(obj.delete());
  }
  }

Output:-

Enter the Elements in the Queue:- 
2
6
9
65
4
Elements which you want to delete? 
2
Deleted Elements: 
2
6