Java 中的三元组 [英] Triples in Java
本文介绍了Java 中的三元组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能的重复:
Java 需要元组吗?
Java 是否支持三元组或至少是成对的?Java 是否支持元组?我试图找到一种方法来制作一个列表,以便它有一个三元组,首先是起点,最后是终点,中间是距离.但是,我似乎找不到任何关于它的信息.
Does Java support triples or at least pairs? Does Java support tuples? I am trying to find a way to make a list so that it has a triple with initial point as first, terminal point at last, and distance in the middle. However, I can't seem to find anything about it.
推荐答案
我通常只是出于这些目的创建自己的类.
I usually just create my own class for these purposes.
class Pair<A,B> {
A a;
B b;
public Pair( A a, B b ) {
this.a = a;
this.b = b;
}
}
这篇关于Java 中的三元组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文