Here you can find the source of castObject(Class
public static <T> T castObject(Class<T> clazz, Object object)
//package com.java2s; //License from project: Open Source License public class Main { public static <T> T castObject(Class<T> clazz, Object object) { return clazz.cast(object); }//from w ww. j a va 2 s. co m }