1

I am working through Data Algorithms book and

I am getting the following compilation error when trying to access Tuple2 members in Java:

I admit, that I am newish to Scala but the syntax looks right, per scala-lang so any help is appreciated. Thanks

_1 has private access in scala.Tuple2
_2 has private access in scala.Tuple2

The code snippet in question

List<Tuple2<String, Iterable<Tuple2<Integer,Integer>>>> output2 = groups.collect();
for(Tuple2<String, Iterable<Tuple2<Integer,Integer>>> t : output2){

        Iterable<Tuple2<Integer,Integer>> list = t._2;
        System.out.println(t._1);
        for(Tuple2<Integer,Integer> t2 : list){

                System.out.println(t2._1 + "," + t2._2);
        }

}

1 Answer 1

3

You have to include the parentheses in java. t2._2() and t2._1(). Scala has a shortcut where parentheses can be omitted from zero arg methods.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.