commons-lang3包
两个参数:MutablePair(可修改)、ImmutablePair,三个参数:MutableTriple(可修改)、ImmutableTriple(不可修改)
包commons-lang3 3.8.1里就有
org/apache/commons/lang3/tuple/ImmutableTriple.java
javatuples包
还有一个强大的包javatuples
<dependency>
<groupId>org.javatuples</groupId>
<artifactId>javatuples</artifactId>
<version>1.2</version>
</dependency>
JavaTuples提供以下类来使用:
JavaTuples最多允许10个元组。每个类都是:
For 1 element - Unit
For 2 elements - Pair<A, B>
For 3 elements - Triplet<A, B, C>
For 4 elements - Quartet<A, B, C, D>
For 5 elements - Quintet<A, B, C, D, E>
For 6 elements - Sextet<A, B, C, D, E, F>
For 7 elements - Septet<A, B, C, D, E, F, G>
For 8 elements - Octet<A, B, C, D, E, F, G, H>
For 9 elements - Ennead<A, B, C, D, E, F, G, H, I>
For 10 elements - Decade<A, B, C, D, E, F, G, H, I, J>
JavaTuples还提供了2个非常常见的2元素元组类,相当于Pair:
KeyValue <A,B>
LabelValue <A,B>