如何在java控制台输入数组?

如题所述

import java.io.*;
public class arraySystemin {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int[] a = new int[10];
try{
for(int i = 0; i < a.length ; i++){
System.out.print("请输入第" + i +"个数: ");
String s = bt.readLine();
a[i] = Integer.parseInt(s);
}
for(int i =0; i < a.length; i++){
System.out.println("输入的第" + i + "个数为: " + a[i]);
}
}catch(Exception e){
e.printStackTrace();
}
我用的IO流来输入的,LS的要简单些
温馨提示:答案为网友推荐,仅供参考
相似回答