Package java.lang

Class Class<T>

    • Method Detail

      • forName

        public static Class<?> forName​(String className)
                                throws ClassNotFoundException
        Returns a Class object which represents the class with the given name. The name should be the name of a non-primitive class, as described in the class definition. Primitive types can not be found using this method; use int.class or Integer.TYPE instead.

        If the class has not yet been loaded, it is loaded and initialized first. This is done through either the class loader of the calling class or one of its parent class loaders. It is possible that a static initializer is run as a result of this call.

        Parameters:
        className - Name of the class.
        Returns:
        Class
        Throws:
        ClassNotFoundException - if the requested class can not be found.
        LinkageError - if an error occurs during linkage
        java.lang.ExceptionInInitializerError - if an exception occurs during static initialization of a class.
      • getName

        public String getName()
        Returns the name of the class represented by this Class. For a description of the format which is used, see the class definition of Class.
        Returns:
        Name of the class.
      • toString

        public String toString()
        Description copied from class: Object
        Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data.
        Overrides:
        toString in class Object
        Returns:
        a printable representation of this object.