allocating for array and then using constructor

后端 未结 3 871
终归单人心
终归单人心 2021-01-21 05:23

Person.java

public class Person {
    public String firstName, lastName;

    public Person(String firstName,
            String lastName) {
        this.firstN         


        
3条回答
  •  旧巷少年郎
    2021-01-21 05:56

    Person[] people = new Person[20];
    

    only allocates memory for objects Person (filled with nulls). Then you need to fill it with particular Persons (with random name and surname int this example).

提交回复
热议问题