This content has been marked as final. Show 6 replies
Common question--third time I've seen it today (always worded slightly differently).
Use a Map:
(The left side of the declaration of the "map" variable could be a Map, instead of a HashMap. The right needs to be a HashMap. For your code, you'll probably want a "Map < String , String >".)
You're trying to name the arraylist with the value in the fieldName. You cannot do that. This is because the left side of a declaration should be a variable not a value. You might want to try and use a Map.
Why an ArrayList<Char>? A list of characters? What for?
Please read all the excellent feedback then note:
A char and Character are only single characters.
When you read a line with:
It returns a String which is a Special Object for handling the common case of many char's in an array of char.
So change your char to java.lang.String or just String since you automagically
get : import java.lang.*;
Read up on java.lang.String in the JavaDoc it is a very powerful tool that Java provides.
Good luck and keep asking questions, its how we learn.
Also "Char" means nothing. Please remember that Java is case sensitive.
If you want the Object version of the primitive char then you need to use Character
one last thing....
When in doubt about a program in java and you are not sure why something
does not work or in this case it should not compile....
Carefully examine the compiler output.
Its there to help you resolve these issues.