【发布时间】:2016-11-26 05:43:01
【问题描述】:
所以我有这个代码:
public static void main (String[] args) throws IOException
{
Queue popcorn = new LinkedList();
BufferedReader in = null;
int j = 0;
try {
File file2 = new File("Events.txt");
in = new BufferedReader(new FileReader(file2));
String str;
String [][] process = new String[][];
while ((str = in.readLine()) != null) {
String[] arr = str.split(" ");
for(int i=0 ; i<str.length() ; i++){
process[j][i] = in.readLine();
}
j++;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
它不起作用。它抛出“变量必须提供维度表达式或数组 初始化器”
我正在尝试在此网页回答“http://www.chegg.com/homework-help/questions-and-answers/hired-biggy-s-popcorn-handle-popcorn-orders-store-write-java-console-application-reads-dat-q7220573”之后对其进行建模 我很确定这是行不通的。无论如何,这个链接列表似乎没有奏效。就我的 String[][] 进程声明而言,有人能指出我正确的方向吗?
【问题讨论】:
-
new String[][]- 不可能 创建 没有维度的数组,这就是消息所说的。这与变量声明是分开的。搜索一般提示/方向的错误消息。 -
您需要提供数组大小。阅读java67.com/2014/10/…