使用nextInt()等接受输入时务须注意换行符的输入

使用nextInt()等接受输入时必须注意换行符的输入参考http://stackoverflow.com/questions/19331426/for-lo

使用nextInt()等接受输入时必须注意换行符的输入

参考http://stackoverflow.com/questions/19331426/for-loop-does-not-iterate-the-way-i-want

见以下代码:

System.out.print("Enter name:");s.name = sc.nextLine();System.out.print("Enter number:");//解决方法二:s.number = Integer.parseInt(sc.nextLine());