public class Person {
public String firstName, lastName;
public Person(String firstName,
String lastName) {
this.firstN
new Person[20]
creates an array that can hold 20 references to Person
objects. It does not create any actual Person
objects.
new Person(...)
creates a Person
object.
The critical distinction to make here is that unlike in C or C++, new Person[20]
does not allocate memory for 20 Person
objects. The array does not contain the actual objects; it only contains references to them.