I got ArrayStoreException occured in line-9 when I run the following code:
<CODE>
1 public static void main(
String[] args) throws IOException {
2 BufferedReader br = new BufferedReader(new FileReader("data.txt"));
3 List lines = new ArrayList();
4 for(String line = br.readLine();line != null;line = br.readLine()) {
5 // split by comma
6 String[] fields = line.split(",");
7 lines.add(fields);
8 }
9 String[][] strings = (String[][]) lines.toArray(new String[lines.size()][]);
10 System.out.println("Lines="+strings.length);
11 }
</CODE>
Can anyone help me why it throw exception?
Thanks