I have a problem which I am not sure why its happening. I have an ArrayList which i add String arrays to (String). Then I call the ArrayList's toArray method to convert the array list to an array of String arrays, i.e. a 2 dimensional array.
A call to: myArrayList.toArray(new String); will return an array of Strings (String). If i was to have a list of String arrays in the array list already, shouldn't I be able to cast the returned String array to a 2 dimensional array? (String).
When I do that I get a class cast exception. Dosn't it make sence what I am doing? I hope I made myself clear.
hi James: arrays are java.lang.Object, no matter what type they are holding. So, an ArrayList that contains String arrays, is an ArrayList contains objects. If you want to convert the ArrayList to an ordinarry array, you need to type: