Here you can find the source of cast(final Object o)
SuppressWarnings("unchecked")
annotations).
Parameter | Description |
---|---|
o | Object which is presumably of type T |
T | type to cast to |
@SuppressWarnings("unchecked") public static <T> T cast(final Object o)
//package com.java2s; //License from project: BSD License public class Main { /**//from w w w .j a v a2s . c o m * Utility method to perform generic casts without dealing with <i>Unchecked cast</i> warnings * (or having to apply <code>SuppressWarnings("unchecked")</code> annotations). * @param o Object which is presumably of type T * @param <T> type to cast to * @return the object as instance of T */ @SuppressWarnings("unchecked") public static <T> T cast(final Object o) { return (T) o; } }