Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

list in list

import java.util.*;

public class JavaHungry
{
    public static void main(String[] args)
    {
        // Create listOfLists in Java
        List<List<Integer>> listOfLists = new ArrayList<>();
        
        // Creating innerList 
        List<Integer> innerList = new ArrayList<>();
        
        // Adding elements to innerList
        innerList.add(1);
        innerList.add(2);
        innerList.add(3);
        
        // Adding innerList to listOfLists
        listOfLists.add(innerList);
        
        // Creating another inner list 
        List<Integer> innerList2 = new ArrayList<>();
        
        // Adding elements to innerList2
        innerList2.add(100);
        innerList2.add(101);
        innerList2.add(102);
        
        // Adding innerList2 to listOfLists
        listOfLists.add(innerList2);        

        // Printing listOfLists elements
        System.out.println(listOfLists);
    }
}
Source by javahungry.blogspot.com #
 
PREVIOUS NEXT
Tagged: #list #list
ADD COMMENT
Topic
Name
7+2 =