Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

2d arraylist in java

int vertexCount = 3;
ArrayList<ArrayList<Integer>> graph = new ArrayList<>(vertexCount);
//Next, we'll initialize each element of ArrayList with another ArrayList:

for(int i=0; i < vertexCount; i++) {
    graph.add(new ArrayList());
}
 
PREVIOUS NEXT
Tagged: #arraylist #java
ADD COMMENT
Topic
Name
4+9 =