Online Java Compiler By
JavaTpoint.com
import java.util.LinkedList; import java.util.List; public class JavaListIndexOfExample1 { public static void main(String[] args) { List
list= new LinkedList<>(); for (int i=0;i<6;i++){ list.add(i); // returns the element at the specified position in this list int value =list.indexOf(i); System.out.println("Element stored at index "+i+" : "+value); } } }
Output