title: Getting 10 numbers from users and storing it in an array using Java
body: <p>I am trying to make practice application by getting 10 numbers from users and adding them to an array. here is my code</p>
  
  <pre><code>public static void getNumber(){
          for(int i=0; i&lt;10; i++){
          Scanner scanner = new Scanner(System.in);
          System.out.println("Enter number " + i );
          int NumbersArray[] = {};
          int no1 = scanner.nextInt();
          NumbersArray[i] = no1;
          System.out.println(NumbersArray);
          }
  </code></pre>
  
  <p>The problem is that after accepting first value it gives an error message saying </p>
  
  <pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at Number.getNumber(Number.java:17)
      at Number.main(Number.java:8)
  </code></pre>
  
  <p>Line number 8 as per my format is </p>
  
  <pre><code>getNumber();
  </code></pre>
  
  <p>And Line number 17 as per my format is </p>
  
  <pre><code>NumbersArray[i] = no1;
  </code></pre>
  
  <p>Please help</p>