Cast to multidimensional arrays
From: Jay (rt987_at_hotmail.com)
Date: 01/30/04
- Next message: The Ghost In The Machine: "Re: Mars Rover Not Responding"
- Previous message: Anton Spaans: "Re: Directory Upload"
- Next in thread: BarryNL: "Re: Cast to multidimensional arrays"
- Reply: BarryNL: "Re: Cast to multidimensional arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Jan 2004 08:13:04 -0800
Why does the following code produce a ClassCastException?
ArrayList list = new ArrayList();
list.add(new Object[]{"Test1", "..."});
list.add(new Object[]{"Test2", "..."});
list.add(new Object[]{"Test3", "..."});
Object ar[][] = (Object[][]) list.toArray();
The last line causes a ClassCastException... Yet, list.toArray() is
just an array of objects which are themselves arrays of objects. So
list.toArray is an Object[][], conceptually. Why does Java complain?
- Next message: The Ghost In The Machine: "Re: Mars Rover Not Responding"
- Previous message: Anton Spaans: "Re: Directory Upload"
- Next in thread: BarryNL: "Re: Cast to multidimensional arrays"
- Reply: BarryNL: "Re: Cast to multidimensional arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]