Java Class Load classForName(String typeName)

Here you can find the source of classForName(String typeName)

Description

class For Name

License

Open Source License

Declaration

public static Class<?> classForName(String typeName) 

Method Source Code

//package com.java2s;

public class Main {
    public static Class<?> classForName(String typeName) {

        if (typeName.equals("boolean"))
            return boolean.class;
        if (typeName.equals("byte"))
            return byte.class;
        if (typeName.equals("char"))
            return char.class;
        if (typeName.equals("short"))
            return short.class;
        if (typeName.equals("int"))
            return int.class;
        if (typeName.equals("long"))
            return long.class;
        if (typeName.equals("float"))
            return float.class;
        if (typeName.equals("double"))
            return double.class;

        try {// w  w  w  .ja v a 2s . c  o  m
            return Class.forName(typeName);
        } catch (ClassNotFoundException e) {
            return null;
        }
    }
}

Related

  1. classForName(String name)
  2. classForName(String name)
  3. classForName(String name, ClassLoader classLoader)
  4. classForName(String str)
  5. classForName(String typeName)
  6. classForNameNoThrow(String className)
  7. classForNameOrNull(final String className)
  8. classForNameOrPrimitive(String name, ClassLoader loader)
  9. fromString(Class clazz, String stringValue)