import java.io.*;
public class list {
public static void main(String[] args) {
String input;
try {
for (int i = 0; i < 3; i++) {
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
input = br.readLine();
args[i] = input; }
} catch (IOException e) {
System.err.println("IOException"); } for (int j = 0; j < args.length; j++)
System.out.println(args[j]); }}输入q w e
输出的结果为q w e n
连试好几次,为啥会有一个n呢?
public class list {
public static void main(String[] args) {
int n=3;
args=new String[3];
String input;
try {
for (int i = 0; i < n; i++) {
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
input = br.readLine();
args[i] = input; }
} catch (IOException e) {
System.err.println("IOException"); } for (int j = 0; j < args.length; j++)
System.out.println(args[j]); }}
input = br.readLine();这句话每次输入的是一个字符串,包括空格,也就是说input="q w e";
我这里运行出来抛出ArrayIndexOutOfBoundsException异常LZ你没有错误吗?