I have confused myself with typecasting with this problem.
I have an ArrayList of chars that I want to convert into a String—an array of chars. So it goes something like this:
ArrayList<Character> message = new ArrayList<Character>();
String stringMessage = new String;
stringMessage = message.toArray(stringMessage);
Now the error that is given is:
"Syntax error, maybe a missing semicolon?"
which isn't very helpful.
Is there something wrong with how I cast this? Is it not possible to convert an ArrayList of characters into a String?
new String<-- error here. Andmessage.toArray()will only accept an array as an argument, whichstringMessageis not.toArrayacceptedStringas argument (It doesn't), it still returns an arrayString stringMessage;. But what are you really trying to do? The third line doesn't make sense.