fork download
  1. /*Arrays store a fixed number of values.
  2. *They have many values, but one of the first ways
  3. *you are going to see them is probably going to be
  4. *like the following. Say you declare an array of
  5. type String called names an index of 10...*/
  6.  
  7. String[] names = new names[9]; //-- (The first index is 0, so the array ends at 9)
  8.  
  9. //Then you add some values that you want to be stored
  10.  
  11. names[0] = PizzaGuy;
  12. names[1] = GrillMan;
  13. names[2] = SousChef;
  14.  
  15. //You create a loop that will get user inputs to store a value in each index
  16. //This can be very convenient. Then you can print them out like:
  17.  
  18. System.out.println("You ordered pizza, " + names[0] + " is on his way.");
  19.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:7: class, interface, or enum expected
String[] names = new names[9];  //-- (The first index is 0, so the array ends at 9)
^
Main.java:11: class, interface, or enum expected
names[0] = PizzaGuy;
^
Main.java:12: class, interface, or enum expected
names[1] = GrillMan;
^
Main.java:13: class, interface, or enum expected
names[2] = SousChef;
^
Main.java:18: class, interface, or enum expected
System.out.println("You ordered pizza, " + names[0] + " is on his way.");   
^
5 errors
stdout
Standard output is empty