title: String array in implemenation a Queue
body: <p>I'm currently studying data structure &amp; i'm trying to make a string array in java using a queue. 
  I want the user to inserts how many element then inserts them (example students name).
  but the code won't work, can you help telling me where is the error? </p>
  
  <pre><code>package test;
  import java.util.Scanner;
  class queue{
      String arr[];
       int size;
      private int front;
      private int rear;
      private int items;
      queue(int s){
          size=s;
      String arr[]=new String[size];
          front=0;rear=-1;
          items=0;
      }
  public void insert(int x){
  if(rear==size-1){
  rear=-1;
  arr[++rear]=x;
  items++;
  }
  }
  public String remove(){
  String temp=arr[front++];
  if(front==size){
  front=0;
  items--;
  }
  return temp;
  }
  public boolean isEmpty(){
  return (items==0);
  }
  public boolean isFull(){
  return (items==size);
  }
  public int n(){
  return items;
  }}
  public class Test {
      public static void main(String[] args) {
          Scanner in=new Scanner(System.in);
          queue ob=new queue(4);
          System.out.println("How many elements?");
          ob.size=in.nextInt();
  
           System.out.println("Enter names:");
                 for( int i=0;i&lt;ob.size;i++){ 
              ob.arr[i]=in.nextLine();
          }
          System.out.println("*** Names ***");
          for(int i=0; i&lt;ob.size;i++){ 
              System.out.println(ob.arr[i]);
          }
      }}
  </code></pre>
  
  <p>i get this error for this line </p>
  
  <pre><code>arr[++rear]=x;
  </code></pre>
  
  <p>that says "int cannot be converted to string"</p>
  
  <p>also when i run the code this error appears too : 
  NullPointerException</p>
  
  <p>***** Update ***** 
  new code in main, <strong>it works</strong> :) </p>
  
  <pre><code>    public static void main(String[] args) {
      Scanner in=new Scanner(System.in);
      int size;
      System.out.println("How many elements?");
       size=in.nextInt();
     queue ob=new queue(size);
       System.out.println("Enter names:");
             for( int i=0;i&lt;size;i++){ 
          ob.arr[i]=in.nextLine();
      }
      System.out.println("*** Names ***");
      for(int i=0; i&lt;size;i++){ 
          System.out.println(ob.arr[i]);
      }
  }
  </code></pre>
  
  <p>and in the queue constructor: </p>
  
  <pre><code>arr=new String[size];
  </code></pre>