java - 为什么姓氏紧跟在名字之后而名字仍然为空
问题描述
for(int i=0; i<n; i++) {
System.out.println("Enter Employee "+(i+1)+" Details:");
System.out.flush();
System.out.println("Enter the FirstName");
String f=sc.nextLine();
System.out.println("Enter the LastName");
String l=sc.nextLine();
System.out.println("Enter the Mobile");
String m=sc.nextLine();
System.out.println("Enter the Email");
String e=sc.nextLine();
System.out.println("Enter the Address");
String a=sc.nextLine();
Employee x=new Employee();
x.setDetails(f, l, m, e, a);
E.add(x);
}
那是循环,E 是 Employee 类的 Arraylist。输入第一个员工详细信息时,名字字段保持为空。我不明白为什么会发生 以下输出
解决方案
推荐阅读
- php - 在 php 中从 JSON 打印特定数据
- java - javax.mail.MessagingException:无法连接到 SMTP 主机:email-smtp.us-east-1.amazonaws.com,端口:25;
- python - 将特定行插入数据框中的其他组
- fortran - Fortran 整数的位大小
- google-apps-script - 我可以在没有电子表格的情况下从 Google 表单触发脚本吗?
- java - 如何在签名中没有 RedirectAttributes 的方法中访问 RedirectAttributes?
- python-3.x - 如何将reduce函数的每次迭代存储在列表中?
- javascript - 数据树的问题
- php - 如何使用管道 bitbucket laravel 推送供应商文件夹
- csv - 自动化:将数据从本地 CSV 推送到 Kusto db 表