Arrays in Java

Array are used to hold a list of values ,like a list of Strings,ints etc. Arrays have a fixed length and that is there disadvantage over other collection types like lists

Two ways of defining an array. We can either define an array and all its values there itself or we can define them one by one in coming lines. to find length of array we use length

int[] myArray = {10, 20, 30, 40}

or

String[] cars  = new String[3];

Reference vs values

String[] stringArray = new String[3];

Here stringArray is reference and newString[3] is a value

Two references can point to same value

String[] anotherStringArray = stringArray

Above the newly created reference will point to the same value to which stringArray is pointing to

And we can also make a reference to point to a new value

string Array = new String[3]