public static int askingAmount() {
System.out.println("How many persons are there in your company?");
Scanner amountS = new Scanner(System.in);
amount = amountS.nextInt();
System.out.println(amount);
amountS.close();
return amount;
}
public static void makingPersons() {
for (int i=0 ; i<amount ; i++) {
int personNumber=0;
Person person[i] = new Person(); //<--- The problem
System.out.println("person");
}
}
在第一种方法中,我试图询问用户他们有多少人,然后返回金额。在第二部分中,我想创建一个等量的Person对象,并使用变量“i”将它们命名为person1,person2,person3,但我没有得到它的工作。任何线索?在for循环中启动对象