所以我有這樣的代碼:鏈接列表中的多維數組無法正常工作?
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 [] []過程聲明而言,有人能指出我正確的方向嗎?
'新的String [] []' - 這是不可能的* *創建無維數組,這是信息說什麼。這與變量聲明是分開的。搜索關於一般提示/方向的錯誤消息。 – user2864740
您需要提供數組大小。閱讀http://www.java67.com/2014/10/how-to-create-and-initialize-two-dimensional-array-java-example.html – Rohan