I cannot access Multiple ArrayList element. The code is given below and it cannot access the values 5 or 6. My IDE is not accepting the last statement of my code which is System.out.println(specification.get(0).get(0).value); How can I get the elements of an Object in ArrayList which is within an array list.
class Node {
int value;
boolean explored;
Node(int v) {
value = v;
explored = false;
}
int getValue() {
return value;
}
}
class Board {
ArrayList<ArrayList> specification;
ArrayList<Node> speci_node;
Board() {
speci_node = new ArrayList<Node>(1);
speci_node.add(new Node(5));
speci_node.add(new Node(6));
specification = new ArrayList<ArrayList>(1);
specification.add(speci_node);
System.out.print(specification.get(0).get(0).value); // variable 'value' is not found error....
}
}