Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    @SuppressWarnings("unchecked")
    public static <T> T objectCast(Object obj, Class<T> classToCast) {
        if (obj == null)
            return null;
        Class<? extends Object> curClass = obj.getClass();
        if (classToCast.isAssignableFrom(curClass))
            return (T) obj;
        return null;
    }
}