Java basics
forName()
The java.lang.Class.forName(String className) method returns the Class object associated with the class or interface with the given string name.
Syntax:public static Class> forName(String className) throws ClassNotFoundException
Example:import java.lang.*;
public class ClassDemo {
public static void main(String[] args) {
try {
// returns the Class object for the class with the specified name
Class cls = Class.forName("java.lang.ClassLoader");
// returns the name and package of the class
System.out.println("Class found = " + cls.getName());
System.out.println("Package = " + cls.getPackage());
}
catch(ClassNotFoundException ex) {
System.out.println(ex.toString());
}
}
}
Content
License.
All information of this service is derived from the free sources and is provided solely in the form of quotations.
This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 214 / 158778228. Delta: 0.02863 с