Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Monday, November 19, 2007

java Array initial values

zero/null/false If no initial values are specified for array elements (see below), array elements are initialized to zero for numbers, null for object references, and false for booleans. This is the same as for all object fields.
Initialization A curly brace surrounded list of values can be specified on the declaration. This allocates exactly enough space to hold the array. The following are equivalent.
String[] names = {"Mickey", "Minnie", "Donald"};
String[] names = new String[3];
names[0] = "Mickey";
names[1] = "Minnie";
names[2] = "Donald";

No comments:

Post a Comment

Archives