What exception do you get? What type does the Map use for Keys? What type does the Map use for Values? What is the parameter the Map expects in the get() method? What type are you giving as the parameter to the get() method?
posted 3 years ago
In the map.get(...) method, the argument is the key. Which means that it looks like you're trying to use an AllowanceDTO object as the key, whereas in fact it's the value.
Now, if you'd declared your map variable properly - e.g. as a Map<String, AllowanceDTO> - then that would give you a compile time error rather than an exception. But if you declared it as a plain Map then the compiler wouldn't protect you like that. You haven't shown us where it is declared.
If you've declared it as a plain Map (or TreeMap), the error is probably because it's trying to cast your AllowanceDTO object to a Comparable - because that's how TreeMaps work - but it probably isn't one.
It is difficult to free fools from the chains they revere - Voltaire. tiny ad: