How to Add ArrayList into Another ArrayList Java Code

In this tutorial you will learn How to Add ArrayList into Another ArrayList Java Code. Very simple program for beginners.
        ArrayList> nodes = new ArrayList>();
        ArrayList nodeList = new ArrayList();
        ArrayList nodeList2 = new ArrayList();
        ArrayList getResults = new ArrayList();
        //add data
        nodeList.add(200);
        nodeList.add(300);
        nodeList2.add(201);
        nodeList2.add(301);
        //add arraylist into main arraylist
        nodes.add(nodeList);
        nodes.add(nodeList2);
        
        getResults = nodes.get(0); //get arraylist from main arraylist
        System.out.println(getResults.get(0));

How to Add ArrayList into Another ArrayList Java Code How to Add ArrayList into Another ArrayList Java Code Reviewed by N Jahaan on 02:24 Rating: 5