java类库详细讲解
源代码在线查看: superclass.html
Getting the Superclass of an Object
(Java Developers Almanac Example)
BODY CODE {font-family: Courier, Monospace; font-size: 11pt} TABLE, BODY {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt} PRE {font-family: Courier, Monospace; font-size: 10pt} H3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11pt} A.eglink {text-decoration: none} A:hover.eglink {text-decoration: underline} -->
The Java Developers Almanac 1.4
Order this book from Amazon.
Home
>
List of Packages
>
java.lang
[58 examples]
>
Classes
[11 examples]
e62.
Getting the Superclass of an Object
Object o = new String();
Class sup = o.getClass().getSuperclass(); // java.lang.Object
// Superclass of Object is null
o = new Object();
sup = o.getClass().getSuperclass(); // null
// Although the type of o2 is an interface, getSuperclass() returns the object's superclass
Runnable o2 = new Runnable() {
public void run() {
}
};
sup = o2.getClass().getSuperclass(); // java.lang.Object
Related Examples
e59.
Getting a Class Object
e60.
Getting the Name of a Class Object
e61.
Determining If a Class Object Represents a Class or Interface
e63.
Getting the Superclass of a Class Object
e64.
Listing the Interfaces That a Class Implements
e65.
Listing the Interfaces That an Interface Extends
e66.
Getting the Package of a Class
e67.
Determining from Where a Class Was Loaded
e68.
Loading a Class That Is Not on the Classpath
e69.
Dynamically Reloading a Modified Class
See also:
Arrays
Assertions
Commands
Numbers
Objects
Strings
System Properties
Threads
© 2002 Addison-Wesley.