Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6577867

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:41:40+00:00 2026-05-25T15:41:40+00:00

Why isn’t there a (standard, Java certified) solution, as part of the Java language

  • 0

Why isn’t there a (standard, Java certified) solution, as part of the Java language itself, to return multiple values from a Java method, rather than developers having to use their own means, such as Maps, Lists, Pairs, etc.? Why does Java not support n-tuple objects?

Especially thinking for trivial private methods that may modify two objects together (in tandem), and in which case a typed-object as a return sounds overkill.

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:41:41+00:00Added an answer on May 25, 2026 at 3:41 pm

    I assume the OP means “Why does Java not support n-tuple objects?”.
    Python, Haskell, Lisp, ML etc have heterogeneous n-tuple capabilities. Also often times the ability to apparently return multiple objects in a language is syntactical sugar (ie in python return ‘a’,’b’).

    The reason of course is language design and consistency. Java prefers being very explicit and does not like anonymous data structures (although I wish we had anonymous closures).

    For example in Java there is no way to say I would like a callback that takes these type parameters and returns this. Some people feel this a huge weakness others like the consistency and explicitness.

    IMHO although its annoying I frequently combat this issue by making static inline classes:

    private static class Combo {
       String name;
       int weight;
    }
    

    Yes its tedious but then later on I often reuse and refactor those classes making them top level and adding behavior. Infact one of the advantages with going this route is that its much easier to add new fields where is the anonymous data structure (like in FP languages) it becomes much more difficult to add a field (you end up changing a ton of code).

    I should note that for 2-tuples some people use (or abuse) java.util.Map.Entry as there is an java.util.AbstractMap.SimpleEntry in Java 6. Also Some people now use Commons Lang3’s Pair support (2-tuple).

    Scala has n-tuple support by sort of cheating and having a whole bunch of 2-16 tuple interfaces that are standard in the language and are syntactically hidden from the programmer.

    For purely educational reasons you may want to see how other languages accomplish this.

    UPDATE: for Java 8

    Java 8 will/maybe (so heres my number… call me maybe) support an interface called java.lang.BiValue with a concrete implementation that you can use called java.lang.BiVal . These classes are to help support the new lambda functionality. But notice this is only for 2-tuples.

    UPDATE: for 2015

    Java 8 did not gain support for tuples.

    UPDATE: from author 2015

    If you still would like tuple support there are three libraries that support tuples well:

    • javatuples – Supports JDK 5 and above. Up to 10-tuple.
    • JOOλ – From the author of jOOQ but requires JDK 8.
    • Commons Lang 3 – Now supports a Triple (3-tuple) and supports JDK 6 and above.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Isn't there a way with Hibernate to return a list of (primitive) values from
Isn't there a better looking statement (or way) to keep the console from disappearing
Isn't there a Design Pattern who describes how to high cohesion? I need some
Isn't there a CSS way of having the page to get a border around
Isn't there some way to re-write the following code, such that I don't need
Isn't every language compiled into low-level computer language? If so, shouldn't all languages have
Isn't there a better way to accomplish this?: (RegionID is a Flex ComboBox) RegionID.selectedItem=value.Region;
Why isn't ASP.NET MVC 2.0 part of the .NET 4.0 BCL ?
Isn't this sort of a thumb-rule? Shouldn't this be served from a cookie-less domain?
Isn't there an easy way to select the source files and build them with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.