code: public static <E> List<E> checkedList(List<E> list, Class<E> type) {
          return (list instanceof RandomAccess ?
                  new CheckedRandomAccessList<>(list, type) :
                  new CheckedList<>(list, type));
      }
docs: Returns a dynamically typesafe view of the specified list.
  Any attempt to insert an element of the wrong type will result in
  an immediate {@link ClassCastException}.  Assuming a list contains
  no incorrectly typed elements prior to the time a dynamically typesafe
  view is generated, and that all subsequent access to the list
  takes place through the view, it is <i>guaranteed</i> that the
  list cannot contain an incorrectly typed element.
  
  <p>A discussion of the use of dynamically typesafe views may be
  found in the documentation for the {@link #checkedCollection
  checkedCollection} method.
  
  <p>The returned list will be serializable if the specified list
  is serializable.
  
  <p>Since {@code null} is considered to be a value of any reference
  type, the returned list permits insertion of null elements whenever
  the backing list does.
  
  @param <E> the class of the objects in the list
  @param list the list for which a dynamically typesafe view is to be
  returned
  @param type the type of element that {@code list} is permitted to hold
  @return a dynamically typesafe view of the specified list
  @since 1.5