title: read from user strings of different length into an array
body: <pre><code>class JavaStringArray
  {
      private String[] toppings = {"Cheese", "Pepperoni", "Black Olives"};
  
      public JavaStringArray()
      {
          int size = toppings.length;
          for (int i = 0; i &lt; size; i++)
          {
              System.out.println(toppings[i]);
          }
      }
  }
  class Main
  {
      public static void main(String[] args)
      {
          JavaStringArray strings = new JavaStringArray();
      }
  }
  </code></pre>
  
  <p>I have written a program to store strings of different lengths into an array in different indexes i wanted to achieve this by letting a user type in the strings of any length but he/she goes to a next index if he/she presses enter key for simplicity i only allow three strings to be stored.... how can i achieve that?</p>