Here you can find the source of cast(Set> set)
Parameter | Description |
---|---|
set | Set |
@SuppressWarnings({ "unchecked" }) public static <T> Set<T> cast(Set<?> set)
//package com.java2s; /*//from ww w . java 2 s .c o m // This software is subject to the terms of the Eclipse Public License v1.0 // Agreement, available at the following URL: // http://www.eclipse.org/legal/epl-v10.html. // You must accept the terms of that agreement to use this software. // // Copyright (C) 2001-2005 Julian Hyde // Copyright (C) 2005-2012 Pentaho and others // All Rights Reserved. */ import java.util.*; public class Main { /** * Casts a Set to a Set with a different element type. * * @param set Set * @return Set of desired type */ @SuppressWarnings({ "unchecked" }) public static <T> Set<T> cast(Set<?> set) { return (Set<T>) set; } /** * Casts a List to a List with a different element type. * * @param list List * @return List of desired type */ @SuppressWarnings({ "unchecked" }) public static <T> List<T> cast(List<?> list) { return (List<T>) list; } }