Here you can find the source of classForName(String name)
public static Class classForName(String name) throws ClassNotFoundException
//package com.java2s; /*// www.j a v a 2s .c o m * Copyright (c) 2000 - 2005 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ import java.util.Map; public class Main { private static Map primitiveTypes; /** * Loads class for name. Unlike <code>Class.forName()</code> handles * primitive types such as <code>int</code>, <code>boolean</code>, etc. * Does not support <code>void</code> although <code>Void.TYPE</code> * exists. * * @return the Class object for the class with the specified name. */ public static Class classForName(String name) throws ClassNotFoundException { Class c = (Class) primitiveTypes.get(name); if (c == null) c = Class.forName(name); return c; } }