Java examples for Reflection:Class
Load class For Name
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String typeName = "java2s.com"; System.out.println(classForName(typeName)); }//from ww w . j a v a 2 s . c o m public static Class<?> classForName(String typeName) { try { return Class.forName(typeName); } catch (ClassNotFoundException e) { return null; } } }