Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    @SuppressWarnings("unchecked")
    static public <T> T dynamicCast(Object object, Class<T> clazz) {
        if (object != null && clazz != null && object.getClass().equals(clazz)) {
            return (T) object;
        }
        return null;
    }

    @SuppressWarnings("unchecked")
    static public <T> T dynamicCast(Object object) {
        if (object != null) {
            try {
                return (T) object;
            } catch (Exception e) {
            }
        }
        return null;
    }
}