int q, k;
String query, s;
q = input.nextInt();
for (k = 0; k < q+1; k++) {
query = input.nextLine();
batch.getResult().add_res(query);
s = (batch.getResult().get_res(k));
//System.out.println(s);
String[] ss = s.split(" ");
for(int l=0;l<ss.length;l++) {
System.out.printf("%s ", ss[l]);
}
System.out.println(ss.length);
System.out.printf("%s \n",ss[3]);
System.out.println();
}
此处代码正确打印出arrayList的内容并返回ss.length = 5
,但是当我打印ss[3]
时,它会显示OutOfBoundsException
。