how to create user defined arraylist in java code example

Example 1: how to create a list in java

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

class scratch{
    public static void main(String[] args) {
        List<Integer> aList = new ArrayList<>();
        List<Integer> lList = new LinkedList<>();
    }
}

Example 2: how add model class to array list

//main class
SomeClass b= new SomeClass();
list.add(b);

//subclass
 Home.MainCategory mainCategory = new Home().getInstranceMainCategory();
                mainCategory.mainCatName = getString(R.string.more);
                mainCategoryList.add(mainCategory);

Tags:

Misc Example