Here you can find the source of castListElem(List
Parameter | Description |
---|---|
list | a parameter |
@SuppressWarnings("unchecked") public static <T, V> List<V> castListElem(List<T> list, V target)
//package com.java2s; //License from project: Creative Commons License import java.util.ArrayList; import java.util.List; public class Main { /**/*w w w . jav a2 s.c o m*/ * Creates a new list of the objects cast as the type passed as target. * <b>WARNING</b>: BESURE YOU KNOW THIS WILL WORK. * * @param list * @return */ @SuppressWarnings("unchecked") public static <T, V> List<V> castListElem(List<T> list, V target) { List<V> result = new ArrayList<V>(list.size()); for (T elem : list) { result.add((V) elem); } return result; } }