我不能只是解决这个问题。我有一个用户类:
public class user {
private String name;
private int age;
public user()
{
}
public String getName()
{
return name;
}
public int getAge()
{
return age;
}
public void setName(String kname)
{
name = kname;
}
public void setAge(int kage)
{
alter = kage;
}
}
我正在我的 userUI 类中创建和列出用户
public class PersonalUI {
public static void main (String args[]) {
int menu = 0;
int i = 0;
while (menu != 3)
{
System.out.println("Please choose: \n (1) Create User \n (2) List User \n (3) Quit");
menu = Console.readInt();
if (menu = 1)
{
User user[i] = new User();
System.out.println("Please enter a name");
String kname = Console.readString();
user[i].setName(kname);
}
}
我的问题:当我收到 User user[i] = new User(); 的错误时,如何创建多个对象 猜我只是做错了