Skip to content
标签
欢迎扫码关注公众号

Java 中使用元组(Tuple) -- javatuples

C# 中用元组是方法返回多个值很方便。Java 中没有类似的关键字,但是找到了一个库提供了类似的功能。

javatuples 提供了 1 到 10 个元素的类:

java
Unit<A> (1 element)
Pair<A,B> (2 elements)
Triplet<A,B,C> (3 elements)
Quartet<A,B,C,D> (4 elements)
Quintet<A,B,C,D,E> (5 elements)
Sextet<A,B,C,D,E,F> (6 elements)
Septet<A,B,C,D,E,F,G> (7 elements)
Octet<A,B,C,D,E,F,G,H> (8 elements)
Ennead<A,B,C,D,E,F,G,H,I> (9 elements)
Decade<A,B,C,D,E,F,G,H,I,J> (10 elements)`</pre>赋值及取值方法跟C#类似:<pre>`String str = ...;
Integer integ = ...;
Double doubleArray = ...;

Triplet<String,Integer,Double> triplet = Triplet.with(str, integ, doubleArray);

String myStr = triplet.getValue0();
Integer myInteg = triplet.getValue1();
Double myDoubleArray = triplet.getValue2();

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.