Basically, I am creating a dynamic 2d ArrayList.
private ArrayList<char[]> myArray;
This code below is done in loop. A few random strings of the "same length" is given to store the all the characters in array.
while (body)
char[] temp = myString.toCharArray();
myArray.add(temp);
So after all the characters are inserted into the ArrayList, I want to convert myArray into a normal array. (why? because it is going to be useful in future) And I think I am doing it wrong here:
charArray = (char[][]) myArray.toArray();
//declaration of 'charArray' is already done at the start of the class.
So the problem is when I try to print the whole 'charArray' just to check, or any elements, I get an "java.lang.NullPointerException" error.
So how do I covert the 2d ArrayList into a normal array ? I tried many different sources but didn't help.
Thank you.