Here's a simple thing that I can't find a simple solution for - so any suggestions will be very welcome...
I have a Map<String, MyClass>
and if it has more than 1 entry I let the user pick a MyClass instance by displaying the keys. No problem there.
If it has exactly one entry I just want to use that single MyClass instance.
The best code I have come up with so far is the horribly tacky(MyClass) myMap.values().toArray()[0];
Surely there's a better way? Someone...?