class TwoTuple<A,B>{
public final A first;
public final B second;
TwoTuple(A a, B b){
first = a;
second = b;
}
class ThreeTuple<A,B,C> extends TwoTuple<A,B>{
public final C three;
public ThreeTuple(A a, B b, C c){
super(a,b);
three = c;
}
一个方法只能返回一个对象,但返回一个元组就可以包含多个对象。
public static TwoTuple<String,Integer> f(){
return new TwoTuple<String, Integer>("hi",99);
}
package net.mindview.util; public interface Generator<T> { T next(); } ///:~
原文:https://www.cnblogs.com/jiangfeilong/p/10365468.html