Skip to main content
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

What is the equivalent of the C++ Pair<L,R> in Java?

Is there a good reason why there is no Pair<L,R> in Java? What would be the equivalent of this C++ construct? I would rather avoid reimplementing my own.

It seems that 1.6 is providing something similar (AbstractMap.SimpleEntry<K,V>), but this looks quite convoluted.

Answer*

Cancel
2
  • 1
    I'm not sure a custom class would help in this case :)
    Nikita Rybak
    –  Nikita Rybak
    2011-04-23 16:49:25 +00:00
    Commented Apr 23, 2011 at 16:49
  • 40
    "The typical reason to do so is to iterate over maps". Really?
    Bennett McElwee
    –  Bennett McElwee
    2011-11-28 22:02:03 +00:00
    Commented Nov 28, 2011 at 22:02

Morty Proxy This is a proxified and sanitized view of the page, visit original site.