0

我正在尝试声明一个我自己滚动list<Tuple<String,String,String>Tuple<String, String, String>课程。

public static void main(String args[]) {
        List<Tuple<String,String,String>> Queries = new List<Tuple<String,String,String>>();
}

这是元组类

public class Tuple<T1, T2, T3> extends java.lang.Object {

private final T1 first;
private final T2 second;
private final T3 third;

public Tuple(T1 first, T2 second, T3 third){
this.first = first;
this.second = second;
this.third = third;
}

public T1 first(){ return first; }

public T2 second(){ return second; }

public T3 third(){ return third; }
}

我在 List 中遇到的错误是

 Cannot instantiate the type List<Tuple<String,String,String>>
4

1 回答 1

9

List是不能直接实例化的接口;尝试一个具体的实现,例如ArrayList

List<Tuple<String,String,String>> Queries = new ArrayList<Tuple<String,String,String>>();

它与您的自定义类无关Tuple,与List界面有关。

于 2013-07-18T21:42:44.543 回答