Skip to content
Programming Updated Dec 2017

How to Add ArrayList into Another ArrayList Java Code

Simple Java code that adds one ArrayList into another, including a list of lists, with an example beginners can copy and run.

Published
Reading time
1 min read
Views
8.7k views
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<arraylist nteger="">> nodes = new ArrayList<arraylist nteger="">>();
        ArrayList<integer> nodeList = new ArrayList<integer>();
        ArrayList<integer> nodeList2 = new ArrayList<integer>();
        ArrayList<integer> getResults = new ArrayList<integer>();
        //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));
</integer></integer></integer></integer></integer></integer></arraylist></arraylist>

Questions & comments

Did this work for you, or did you hit a different error? Ask below and we will help.

Comments are reviewed before they appear.

More like this

More in Programming

Programming

Change Color of An Image In JAVA

In this article we will learn how to Change Color of An Image In JAVA language. This is too much easy tutorial for beginners. BufferedImage img = new BufferedImage(600, 3…

Programming

Easy Way To Draw Line On Image in JAVA

In this article you will learn how to draw line on an image in JAVA language. This is very easy way. You also can store this image in your System. BufferedImage img = new…