Erez Shmiel Erez Shmiel - 1 year ago 104
Android Question

How to add an object to pair of pair list in java?

the list type:

List<Pair<Integer, Pair<Integer, Integer>>> listPairOfPair = null;

I tried these but it didn't work:

listPairOfPair.add(new Pair<Integer, Pair<Integer, Integer>>(1, (2,3));

listPairOfPair.add(new Pair<Integer, Pair<Integer, Integer>>(1, Pair.create(2,3)));

Answer Source

Unfortunately, there is no "nice" syntax to do that. You need to go level by level:

Pair<Integer, Integer> onePair = new Pair<>(1, 2); // assuming that you got such a constructor there!

Pair<Integer, Pair<Integer, Integer>> listOfPair = new ArrayList<>();

List<Pair<Integer, Pair<Integer, Integer>>> listPairOfPair = new ArrayList<>();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download