Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

add elements to arraylist of arraylist in java

class Main {

    public static void main(String[] args) {

        ArrayList < ArrayList < Integer >> mainList = new ArrayList < ArrayList < Integer >> ();

        ArrayList < Integer > subList = new ArrayList < Integer > ();

        for (int i = 0; i < 10; i++) {

            subList = new ArrayList < Integer > ();

            for (int j = i + 1; j < 10; j++) {
                subList.add(element[j])
            }
            mainList.add(subList);
        }

    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #elements #arraylist #arraylist #java
ADD COMMENT
Topic
Name
8+1 =