I have a string:
string[] = {'[','hey', ',' , 'how', ',', 'are', ',', 'you', ']' }
I'm writing this to a hashmap, I want the for loop to ignore all the commas. I tried something like this:
for(int i = 0; i<map.size(); i++){
if(string[i].equals(",")){
break;
}
System.out.println(map.get(string[i]));
}
I know it breaks after the first comma.
output is like : [ hey
I want the output to be: hey how are you
How to solve this?
Aucun commentaire:
Enregistrer un commentaire