在 java 中构建了嵌套的 Tuple2

Constructed nested Tuple2 in java

我正在尝试嵌套 Tuple2,以便为图表上的每个顶点保存三个值:id、weight 和 label。

目前我有:

List<Tuple2<Object,Integer>> vertices = Lists.newArrayList(
         new Tuple2<Object,Integer>(1l,0),
         new Tuple2<Object,Integer>(2l,Integer.MAX_VALUE),
         new Tuple2<Object,Integer>(3l,Integer.MAX_VALUE),
         new Tuple2<Object,Integer>(4l,Integer.MAX_VALUE),
 );

我正在尝试构建嵌套的 Tuple2,如下所示:

List<Tuple2<Object,Tuple2<Integer,String>>> vertices = Lists.newArrayList(
         new Tuple2<Object,Tuple2<Integer,String>>(1l,(0,"A")),
         new Tuple2<Object,Tuple2<Integer,String>>(2l,(Integer.MAX_VALUE,"B")),
         new Tuple2<Object,Tuple2<Integer,String>>(3l,(Integer.MAX_VALUE,"C")),
         new Tuple2<Object,Tuple2<Integer,String>>(4l,(Integer.MAX_VALUE,"D"))
);

但这给了我错误。

你能帮我找出问题所在吗?

谢谢

你得到一个错误,因为你没有初始化内部元组:

List<Tuple2<Object,Tuple2<Integer,String>>> vertices = Lists.newArrayList(
     new Tuple2<Object,Tuple2<Integer,String>>(
       1l, new Tuple2<Integer,String>(0,"A")
     ),
     new Tuple2<Object,Tuple2<Integer,String>>(
       2l, new (Integer.MAX_VALUE,"B")
     )
);