Is there a Java equivalent of KeyValuePair<T, T> (i.e. a single hashmap 'cell') type?
I used to find these very useful in .NET and I'm unsure of any equivalen开发者_Python百科t.
There's Map.Entry<K, V>
, which represents map entries. I'm not a C# programmer, but this seems like the most similar thing to what you want.
Not sure if this is what you're looking for but there's a singleton hashmap:
Map<K, V> map = Collections.singletonMap(key, value);
Maybe you can describe what you would like to do with it?
精彩评论