O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

JavaTuples

A more sophisticated library for tuples in Java is available, and it is called JavaTuples (available at http://www.javatuples.org/). It contains things such as, but not limited to, the following:

  • Pair
  • Triplet
  • Quartet

The library can be easily installed by adding dependencies to the app/build.gradle file:

compile 'org.javatuples:javatuples:1.2'

The use of the library is simple and very simple to the android.util.Pair, as shown:

Observable.just("UserID1", "UserID2", "UserID3")        .map(id -> Triplet.with(id, id + "-access-token",             "third-value"))        .subscribe(triplet -> log(triplet.getValue0(),             triplet.getValue1() + triplet.getValue2()));

However, the library has a much higher overhead in memory compared to android.util.Pair, because ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required