LearnFast.Ninja

Java List example generics

n this tutorial you will see how to create genetic list in Java. Then you will see how to add items to this list and finally you will see how to get item by index.

Working Example Code:

List<String> oList = new ArrayList<String>();

oList.add("Green");

oList.add("Blue");

oList.add("Red");

 

for (int i = 0; i < oList.size(); i++)

{

       System.out.println(oList.get(i));

}


Result:


Tags

java

list generics