ArrayList?studentInfors?=?new?ArrayList();
Scanner?sc?=?new?Scanner(System.in);
for?(int?i?=?0;?i?
StudentInfor?studentInfor?=?new?StudentInfor();
System.out.print("請輸入學生學號:");
studentInfor.setNum(sc.nextLine());
System.out.print("請輸入學生姓名:");
studentInfor.setName(sc.nextLine());
System.out.print("請輸入學生英語分:");
studentInfor.setEglish(sc.nextFloat());
studentInfors.add(studentInfor);
}
return?studentInfors;
當i等于0的時候正常,當運行到i=1時,(studentInfor.setNum(sc.nextLine());
)會自動讀入一個空(好像是換行符),這是為什么?