Returns a dynamically typesafe view of the specified list. Trying to insert an element of the wrong type into this list throws a ClassCastException. At creation time the types in list are not checked for correct type. @param list the list to be wrapped in a typesafe list.
(List<E> list, Class<E> type)
| 2556 | * @return a typesafe list. |
| 2557 | */ |
| 2558 | public static <E> List<E> checkedList(List<E> list, Class<E> type) { |
| 2559 | if (list instanceof RandomAccess) { |
| 2560 | return new CheckedRandomAccessList<E>(list, type); |
| 2561 | } |
| 2562 | return new CheckedList<E>(list, type); |
| 2563 | } |
| 2564 | |
| 2565 | /** |
| 2566 | * Returns a dynamically typesafe view of the specified set. Trying to |