No-space array notation type[]

This commit is contained in:
Antonio Lima 2015-03-15 21:17:52 -04:00
parent bf73893f58
commit 6034688980

View File

@ -103,15 +103,15 @@ public class LearnJava {
// Arrays // Arrays
//The array size must be decided upon instantiation //The array size must be decided upon instantiation
//The following formats work for declaring an array //The following formats work for declaring an array
//<datatype> [] <var name> = new <datatype>[<array size>]; //<datatype>[] <var name> = new <datatype>[<array size>];
//<datatype> <var name>[] = new <datatype>[<array size>]; //<datatype> <var name>[] = new <datatype>[<array size>];
int [] intArray = new int[10]; int[] intArray = new int[10];
String [] stringArray = new String[1]; String[] stringArray = new String[1];
boolean boolArray [] = new boolean[100]; boolean boolArray[] = new boolean[100];
// Another way to declare & initialize an array // Another way to declare & initialize an array
int [] y = {9000, 1000, 1337}; int[] y = {9000, 1000, 1337};
String names [] = {"Bob", "John", "Fred", "Juan Pedro"}; String names[] = {"Bob", "John", "Fred", "Juan Pedro"};
boolean bools[] = new boolean[] {true, false, false}; boolean bools[] = new boolean[] {true, false, false};
// Indexing an array - Accessing an element // Indexing an array - Accessing an element