<<< Populating array of objects | Index | Array length >>> |
The syntax for creating an array and assigning values in one statement
type[] arrayName = {value1, value2, value3, ...};
Examples that create an array and assign values in one statement
double[] prices = {14.95, 12.95, 11.95, 9.95}; String[] names = { "Ted Lewis", "Sue Jones", "Ray Thomas"}; Product[] products = { new Product("java"), new Product("jsps")};
When declaring and initializing arrays, the size of the array is determined by the number of initial values within the braces
If an array is declared and initialized simultaneously, do not use the operator new to instantiate the array object
<<< Populating array of objects | Index | Array length >>> |