Tuesday, May 17, 2011

Declaring an one dimensional array in java

You declare an array variable by specifying the array type—which is the element type followed by []—and the array variable name. For example, here is the declaration of an array a of integers:

int[] a; or int a[];

Note matter of style: Second method is used in cpp or c and can be used in java as well but in java 1st style is preferred because it neatly separates the type int[] (integer array) from the variable name.

No comments:

Post a Comment

Chitika