Specifications

Sun Services
Java™ Programming Language
Module 5, slide 9 of 15
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Initializing Arrays
Initialize an array element.
Create an array with initial values.
String[] names;
names = new String[3];
names[0] = "Georgianna";
names[1] = "Jen";
names[2] = "Simon";
String[] names = {
"Georgianna",
"Jen",
"Simon"
};
MyDate[] dates;
dates = new MyDate[3];
dates[0] = new MyDate(22, 7, 1964);
dates[1] = new MyDate(1, 1, 2000);
dates[2] = new MyDate(22, 12, 1964);
MyDate[] dates = {
new MyDate(22, 7, 1964),
new MyDate(1, 1, 2000),
new MyDate(22, 12, 1964)
};