我有以下课程:
MinMaxArray类:
public class MinMaxArray
{
public static <T> void MinMax(T[] anArray)
{
//return an instance of class Pair
}//MinMax
}//class MinMaxArray
配对课程:
//Two objects grouped into a pair.
public class Pair<FirstType, SecondType>
{
//The first object.
private final FirstType first;
//The second object.
private final SecondType second;
//Constructor is given the two objects.
public Pair(FirstType requiredFirst, SecondType requiredSecond)
{
first = requiredFirst;
second = requiredSecond;
}//Pair
//Return the first object.
public FirstType getFirst()
{
return first;
}//GetFirst
//Return the second object.
public SecondType getSecond()
{
return second;
}//GetSecond
}//class Pair
我不知道如何返回Pair类的实例。不寻找答案,只是一个起点。感谢
答案 0 :(得分:2)
提示您可以创建一个配对,T
作为两种类型。