Hi, I'm having some trouble in writing a piece of code. I'm trying to seach an array, but it has multiple keys. I have currently written code (an if loop nested within a for loop) which will find the first of the keys, but it then stops, not returning the others! If anyone could give me any tips on how to make it carry on searching, it would be much appreciated! Thanks!
If you mean that you are using hashmap,
for example; HashMap<String, Color>....
You may want to use String as your key.... to find the color...
If i am right, then you can use for loop of it...
then try to get the Color from that hashmap...
As long as you know the String, use can implement an iteration that would compare them by all of you strings....just to get the needed color...
like,
- Color c = HashMapObject.get(String);
You can use the HashMapObject to get all the string and use it in loop...
example,
Set<String> key = HashMapObject.keySet();
It returns an array of String (Depends on what you have stored in you
HashMap) that is useful for iteration....
for( Initialize a String here: key)
it will iterate until the last String that you have stored in your
HashMap... then find the color...
If you feel it is too far from my assumptions,
Please be specific,
trying to seach an array
for me is confusing...
Correct me if im wrong,
Sukatoa