![](/img/trans.png)
[英]Java - How to store values of a text file into an array using Scanner?
[英]how use Scanner and push that values to an array in java?
我想將值從Scanner
推送到Array
。 我想知道這段代碼是否正確。 如果錯了怎么辦? 這是我一遍遍調用的方法。 所以我想將該用戶輸入值存儲在Array
。
String[] student_id = new String[150];
String studentId = "";
System.out.print("Enter Student ID : ");
studentId = input.nextLine();
student_id = studentId;
for(int i =0;i<student_id.length;i++) {
student_id[i] = input.nextLine();
}
簡單
String[] student_id=new String[150];
System.out.print("Enter Student ID : ");
for(int i =0;i<student_id.length;i++){
student_id[i] = input.nextLine();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.