title: Reading and storing names in an array from user input
body: <p>I'm currently in the midst of creating a program that takes in 10 names from user input, stores them in an array and then prints them out in upper case. I know there's been similar threads/questions asked but none of them really helped me. As per, any help would be greatly appreciated.</p>
  
  <p>My code:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class ReadAndStoreNames {
  
  public static void main(String[] args) throws Exception {
      Scanner scan = new Scanner(System.in);
      //take 10 string values from user
      System.out.println("Enter 10 names: ");
      String n = scan.nextLine();
  
  
      String [] names = {n};
      //store the names in an array
      for (int i = 0; i &lt; 10; i++){
          names[i] = scan.nextLine();
          }
      //sequentially print the names and upperCase them
      for (String i : names){
          System.out.println(i.toUpperCase());
          }
  
      scan.close();
  
  }
  
  }
  </code></pre>
  
  <p>The current error I'm getting is this (after only 3 inputs I may add):</p>
  
  <pre><code>Enter 10 names: 
  Tom
  Steve
  Phil
  Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
  at ReadAndStoreNames.main(ReadAndStoreNames.java:22)
  </code></pre>