January 2002
Intermediate to advanced
264 pages
8h 3m
English
java.lang.Class
This class is a much smaller counterpart to the J2SE
Class class. It represents a Java class, array, or
interface. A class can be dynamically loaded using the static
forName() method, which takes the fully qualified
name of the class and returns a Class object. The
isArray() and isInterface()
methods test whether the class is an array or interface,
respectively. To test if a specific object is an instance of this
class, pass the object into the isInstance()
method. Use the newInstance() method to create an
object by invoking its zero-argument constructor. Finally,
getResourceAsStream() can be used to load external
resources (such as bitmap images) into an input stream.
public final classClass{ // static methods public static native ClassforName(String className) throws java.lang.ClassNotFoundException; // public instance methods public StringgetName(); public InputStreamgetResourceAsStream(String name); public booleanisArray(); public booleanisAssignableFrom(Class cls); public booleanisInstance(Object obj); public booleanisInterface(); public ObjectnewInstance() throws java.lang.InstantiationException, java.lang.IllegalAccessException; public StringtoString(); }
Read now
Unlock full access