- forNameReturns the Class object associated with the class or interface with the given string name. Invoking this method is equivalent to:Class.forName(className, true, currentLoader)where currentLoader denotes the defining class loader of the current class.Parameters:className - the fully qualified name of the desired class.Returns:the Class object for the class with the specified name.Throws:LinkageError - if the linkage failsExceptionInInitializerError - if the initialization provoked by this method failsClassNotFoundException - if the class cannot be locatedSee Java Language Specification:12.2 Loading of Classes and Interfaces
For example, the following code fragment returns the runtime Class descriptor for the class named java.lang.Thread:
Class t = Class.forName("java.lang.Thread")A call to forName("X") causes the class named X to be initialized.
12.3 Linking of Classes and Interfaces
12.4 Initialization of Classes and Interfaces
댓글 0