java中Scanner nextInt()报错
publicclassTest07{publicstaticvoidmain(String[]args)throwsParseException{Scannerscann...
public class Test07 {
public static void main(String[] args) throws ParseException {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入员工数量:");
int num = scanner.nextInt();
Collection emps = new ArrayList();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(int i=1;i<=num;){
System.out.println("请输入第"+i+"个员工信息");
String info = scanner.nextLine();
String[] data = info.split(",");
String name = data[0];
int age = Integer.parseInt(data[1]); 展开
public static void main(String[] args) throws ParseException {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入员工数量:");
int num = scanner.nextInt();
Collection emps = new ArrayList();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(int i=1;i<=num;){
System.out.println("请输入第"+i+"个员工信息");
String info = scanner.nextLine();
String[] data = info.split(",");
String name = data[0];
int age = Integer.parseInt(data[1]); 展开
1个回答
2017-03-15
展开全部
这个情况,和输入有关,,,,,,~~~~~~~~~~可以捕捉异常、发生异常后,重新初始化scanner
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询