问题:java数组信息输出有误
相关代码:
public static void main(String[] args) throws IOException{
@SuppressWarnings("resource")
BufferedReader br = new BufferedReader(new FileReader("menu.txt"));
br.readLine();
String str;
String[] strArray=new String[]{};
while((str=br.readLine())!=null){
strArray=str.split("\s+");
for(int j=0;j<3;j++) {
if(j==2) {
System.out.println(strArray[j]);
}
else break;
}
}
运行结果及报错内容 :”if(j==2) {
System.out.println(strArray[j]);
}“
输出空白,不知道哪里错了……
想要达到的结果:任意输出strArray数组中的任意元素。