Home Java SCJP SCWCD Servlet Submit News Contact Us Site Map


Over 500 magazines for free (including Oracle Magazine)!

Yes all of them are FREE. You can subscribe to ALL of them.
Click here to apply today!

Home > Java > Java Articles

Java Array Initialization

Once created, array elements can be initialized explicitly using loop or initialization can be combined with the array creation using following syntax.

<type>[] arrayName = { <initialization value list>};

Following is the example of the same.

int [] myIntArray = {1,2,3,4};

Note: initialization list can be legally terminated by comma. For example

int [] myIntArray = {1,2,3,4,};

 

<< Array Creation

Accessing Array Elements >>


Home Java SCJP SCWCD Servlet Site map