get Class By String for Reflection - Java Reflection

Java examples for Reflection:Class

Description

get Class By String for Reflection

Demo Code


//package com.java2s;

public class Main {


     static Class<?> getClassByString(final String className) {
        if (className == null)
            return null;
        try {//from  www . j  a  v  a 2 s.  c  om
            return Class.forName(className);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related Tutorials