Java Array

Categories: Java // Tags: , , .
Email this to someonePrint this pageShare on Google+0Share on Facebook0Tweet about this on TwitterShare on LinkedIn1Share on Reddit0Pin on Pinterest0Share on StumbleUpon1


Java Array
Arrays are a data structure type which is used to store multiple variables of the same type. Arrays can hold Primitives as well as Object.

Note*: Array will always be an Object in Heap.
Array Declaration (Syntax)
Array of Primitives

 

Array Of Object

 

Note: You cannot include size of array in declaration.

Declaration only doesn’t create array object in heap.

Constructing an Array
This is the step where array object will be created on heap. As once created size of the array can not be changed, hence size of the array needs to be provided at the time of constructing it.

Note: Size of the array means how much element an array can contains.
One Dimensional Array
New keyword will be used to construct one dimensional array.

 

Tow Dimensional Array
These are arrays of arrays. So a two dimensional array of array is array of array of int.

 

Note: Only first part(First Dimension is required) needs the size and not the all.

Initializing Array
Once arrays created and space assigned to it next thing would be to add elements in it. Initialization of array is the place where we can do this(Adding Element in array).

Single Dimensional Array

 

Email this to someonePrint this pageShare on Google+0Share on Facebook0Tweet about this on TwitterShare on LinkedIn1Share on Reddit0Pin on Pinterest0Share on StumbleUpon1

About Team

Browse Archived Articles by Team

  • hriday dubey

    good job