Java Class Load classForName(String name)

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

Description

Loads class for name.

License

Open Source License

Return

the Class object for the class with the specified name.

Declaration

public static Class classForName(String name) throws ClassNotFoundException 

Method Source Code

//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;
    }
}

Related

  1. classForName(String cname)
  2. classForName(String columnType)
  3. classForName(String listener)
  4. classForName(String name)
  5. classForName(String name)
  6. classForName(String name)
  7. classForName(String name)
  8. classForName(String name)
  9. classForName(String name)