0
votes

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

1 Answers

3
votes

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.