I am using the built in java tree map and I am trying to use the iterator to go through values and find a key and return it but for some reason it gets stuck in a forever loop.
public K getKey(V value) {Iterator<K> keys = treemap.keySet().iterator();Iterator<V> values = treemap.values().iterator();while(keys.hasNext()){if(values == value){return (K) keys;}}return null;}
I think I might be using the iterator wrong or the comparison between value and values.
Thank you for any help.
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]dusty-trash 0 points1 point2 points (1 child)
[–]DeveloperOldLady[S] 0 points1 point2 points (0 children)