Collections.checkedList(List <E> list, Class <E> type) has the following syntax.
public static <E> List <E> checkedList(List <E> list, Class <E> type)
In the following code shows how to use Collections.checkedList(List <E> list, Class <E> type) method.
import java.util.ArrayList; import java.util.Collections; import java.util.List; /*from w w w . java2 s . com*/ public class Main { public static void main(String args[]) { List<String> arlst=new ArrayList<String> (); arlst.add("A"); arlst.add("B"); arlst.add("C"); arlst.add("from java2s.com"); // create typesafe view of the list List<String> tslst = Collections.checkedList(arlst,String.class); System.out.println(tslst); } }
The code above generates the following result.