我试图嵌套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"))
);
但这给了我错误。
你能帮助我,找出问题所在。
谢谢
答案 0 :(得分:0)
您收到错误,因为您没有初始化内部元组:
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")
)
);