After seeing many people having doubt about using arrays (in Java) and how they are stored, when are they created etc. i decide to do a post on Arrays in Java, to give my readers a broader and clear view about Arrays declaration, creation and intialization.
Definition, Arrays are complex variablesthat store a group of values under a single variable name.
An array is imply a sequence of either objects or primitives, all of the same type and is put together under one identifier name. A specific element in an array is accessed by an index or subscript. The index of the array is in a continuous order whereas all array elements are stored at contiguous memory location.
You can declare arrays of any type, either primitive or class :
Definition, Arrays are complex variablesthat store a group of values under a single variable name.
Declaring Arrays :
An array is imply a sequence of either objects or primitives, all of the same type and is put together under one identifier name. A specific element in an array is accessed by an index or subscript. The index of the array is in a continuous order whereas all array elements are stored at contiguous memory location.
You can declare arrays of any type, either primitive or class :
char[] s;
Point[] p; // Where Point is a class
In Java Programming language, creates a reference to the array that you can use to refer to an array. The actual memory used by the array element is allocated dynamically either by a new statement or by an array initializer.