LearnFast.Ninja

Java List get element by index

In this tutorial you will see how to get list element by index, You need to use the get method and pass int number of the index.

Working Example Code:

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

oList.add("Green");

oList.add("Blue");

oList.add("Red");

 

String Blue = oList.get(1);

System.out.println(Blue);


Result:


Tags

java

list