#126 – Initializing Arrays of Reference-Type Objects

You can also use an array initialization expression to initialize an array of objects that belong to a reference type.

For example, if you have a Book class with a constructor that takes three arguments, you can initialize an array of books this way:

 Book[] books = { new Book("Moby Dick", "Melville", "Herman"),
                  new Book("Ulysses", "Joyce", "James"),
                  new Book("The Great Gatsby", "Fitzgerald", "F. Scott")};

#121 – Array Initialization

You can optionally initialize an array at the time that you declare and instantiate it.  You do this by including an array initialization expression.

 int[] numbers = new int[] { 10, 20, 30, 40 };

You can be even more concise and dispense with the new int[] part.

 int[] numbers = { 10, 20, 30, 40 };