Tuesday, May 17, 2011

Array Initialization in java

Shorthand method

Java has a shorthand to create an array object and supply initial values at the same time. Here's an example of the syntax at work:

int[] smallPrimes = { 2, 3, 5, 7, 11, 13 };

Notice that you do not call new when you use this syntax.

No comments:

Post a Comment

Chitika