Java Class forName() MethodThe forName() method of Java Class class returns the Class object associated with the class or interface with the given name in the parameter as String. SyntaxThis method is overloaded in the following ways. Parametermodule - A module name - The binary name of the class className - the fully qualified name of the desired class. name - the fully qualified name of the desired class initialize - if true the class will be initialized. loader - class loader from which the class must be loaded Returnsclass object representing the desired class. ThrowsLinkageError ,ExceptionInInitializerError , ClassNotFoundException SecurityException Example 1Test it NowOutput: Name of Class = java.lang.ClassLoader Package Name = package java.lang, Java Platform API Specification, version 1.8 Interface Name = [Ljava.lang.Class;@7852e922 Example 2Test it NowOutput: Name of Class = java.lang.ClassLoader Package Name = package java.lang, Java Platform API Specification, version 1.8 Interface Name = [Ljava.lang.Class;@7852e922 Construcors = [Ljava.lang.reflect.Constructor;@4e25154f Classes = [Ljava.lang.Class;@70dea4e Next TopicJava Class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India