📅  最后修改于: 2022-03-11 14:52:08.149000             🧑  作者: Mango
public class Tuple {
// the T is a placeholder for any datatype
public T leftValue;
public T rightValue;
public Tuple(T leftValue, T rightValue){
// again, T is being used as a placeholder for any type
this.leftValue = leftValue;
this.rightValue = rightValue;
}
public class Program{
public static void main (String args){
// And upon using Tuples we can fill in the T from the Tuple class with actual datatypes
Tuple intTuple = new Tuple (5, 500)
Tuple stringTuple = new Tuple ("Hello", "World")
// we can even put Tuples inside of Tuples!
Tuple> metaIntTuple = new Tuple > (intTuple, new Tuple (456, 0));
}
}