I'm looking for a KeyValuePair class in Java.
Since java.util heavily uses interfaces there is no concrete implementation provided, only the Map.Entry interface.
Is there some canonical implementation I can import? It is one of those "plumbers programming" classes I hate to implement 100x times.
The class AbstractMap.SimpleEntry is generic and can be useful.
Android programmers could use BasicNameValuePair
Update:
BasicNameValuePair is now deprecated (API 22). Use Pair instead.
Example usage:
Pair<Integer, String> simplePair = new Pair<>(42, "Second");
Integer first = simplePair.first; // 42
String second = simplePair.second; // "Second"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With