Java Class Load getClass(String className)

Here you can find the source of getClass(String className)

Description

This method returns the class matching the name className.

License

Open Source License

Declaration

public static Class<?> getClass(String className) throws ClassNotFoundException 

Method Source Code

//package com.java2s;
/*/*  w w  w  .jav  a 2  s .  co  m*/
 * %W% %E%
 *
 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.util.*;

public class Main {
    private static final Map<String, Class<?>> primitiveMap = new HashMap<String, Class<?>>();

    /**
     * This method returns the class matching the name className.
     * It's used to cater for the primitive types.
     */
    public static Class<?> getClass(String className) throws ClassNotFoundException {
        Class<?> c;
        if ((c = primitiveMap.get(className)) != null)
            return c;
        return Class.forName(className);
    }
}

Related

  1. fromString(Class enumClass, String s, T defaultValue)
  2. fromString(Class enumType, String text)
  3. fromString(final Class clazz, final String value)
  4. fromString(String string, Class arrayClass)
  5. getClass(Class clazz)
  6. getClass(String className)
  7. getClass(String className)
  8. getClass(String fullClassName)
  9. getClass(String name)