A Map<String,Integer> (use HashMap, not Hashtable) seems like the most obvious choice. For an object, get the current value from the map. If there is no current value or the current value is lower than the new value, overwrite the value. Otherwise do nothing.
Could I ask what the code would look like to do the "If there is no current value or the current value is lower than the new value, overwrite the value. Otherwise do nothing."
was keeping it simple for question but what if the Integer is an Object with one of the values within the object is the value
I can pull the name and value but having problem with getting the oldvalue
Assuming you create a map like Map<String, YourClass>. The only difference is you retrieve the entire object then compare against a property of that object... Is this what you are talking about?
I worked out how to get the oldvalue out but I never used a ternary operator and it is confusing me (I will ask a java dev on monday at work about them)
how would the if-else statement look like using objects
how would the if-else statement look like using objects
Just think of the expression before the "?" mark as what you put inside the "if" statement and the colon (:) act as a the "else" keyword in that notation.