这是我的 User.java 类。
public class User {
private String First_Name;
private String Last_Name;
public String getFirst_Name() {
return First_Name;
}
public void setFirst_Name(String first_Name) {
First_Name = first_Name;
}
public String getLast_Name() {
return Last_Name;
}
public void setLast_Name(String last_Name) {
Last_Name = last_Name;
}
public User(String first_Name, String last_Name) {
super();
First_Name = first_Name;
Last_Name = last_Name;
}
public User() {
// TODO Auto-generated constructor stub
}
}
我想将不同用户的输入作为名字和姓氏。为此,我将 Input.java 类设为:
public class InputLogic {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("How many name you want to enter:");
int num = sc.nextInt();
int i=0;
while(i < num){
User firstname = new User();
System.out.println(i + "Enter First name:");
String firsttemp = sc.nextLine();
firstname.setFirst_Name(firsttemp);
User lastname = new User();
System.out.println(i + "Enter Last name:");
String lasttemp = sc.nextLine();
lastname.setLast_Name(lasttemp);
i++;
}
}
}
这种方法有什么问题......??