Java List Cast cast(List list)

Here you can find the source of cast(List list)

Description

Helper method for cast any List to generic list.

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
public static <T> List<T> cast(List<?> list) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011 Google, Inc./*from w  ww.  j  a v  a 2 s  . co  m*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Google, Inc. - initial API and implementation
 *******************************************************************************/

import java.util.List;

public class Main {
    /**
     * Helper method for cast any {@link List} to generic list.
     */
    @SuppressWarnings("unchecked")
    public static <T> List<T> cast(List<?> list) {
        return (List<T>) list;
    }
}

Related

  1. cast(Class clazz, List list)
  2. cast(final Class cls, final Object[] list)
  3. cast(final Collection list)
  4. cast(final List list)
  5. cast(List list)
  6. cast(List list)
  7. cast(List list, Class klass)
  8. cast(List from)
  9. CAST_LIST(Class className, Object obj)