Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I`m trying to have nested Tuple2, in order to save for each Vertex on my graph three values: id, weight and label.

Currently I have:

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),

And I`m trying to construct the nested Tuple2 like below:

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"))

but this gives me error.

Can you please help me, identifying what is wrong.

Thank you

You get an error because you didn't initialize internal tuples:

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")
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.