The tuple4j provides the tuple for Java.
Pair<Intger, Intger> pair = Pair.of(10, 20);
Systemm.out.println(pair._1); // 10
Systemm.out.println(pair._2); // 20
Pair<String, List<Long>> pair2 = Pair.of("hoge", Arrays.asList(20L, 30L));
org.junit.Assert.Assert.assetEquals(pair2._1, "hoge"); // passed
org.junit.Assert.Assert.assetEquals(pair2._2, Arrays.asList(20L, 30L)); // passed
Triple<Intger, Intger, String> triple = Triple.of(10, 20, "a");
Systemm.out.println(triple._1); // 10
Systemm.out.println(triple._2); // 20
Systemm.out.println(triple._3); // "a"
There are the following reasons for it.
- make it as immutable object
- refer to Tuple of Scaa
<dependency>
<groupId>com.github.poad</groupId>
<artifactId>tuple4j</artifactId>
<version>0.0.2</version>
</dependency>
compile 'com.github.poad:tuple4j:0.0.2'