Browse - Programming Tips - How do I initialize an array of a class?

Date: 2012sep22
Language: Java	
Keywords: init

Q.  How do I initialize an array of a class?

A.

class Person { String first; String last; Person(final String first, final String last) { this.first = first; this.last = last; } } Person[] people = new Person[] { new Person("John", "Smith"), new Person("Steve", "Jobs"), new Person("Bill", "Gates"), };