|
|
|
|||
|
Finding SuperclassesBecause the Java programming language supports inheritance, an application such as a class browser must be able to identify superclasses. To determine the superclass of a class, you invoke thegetSuperclass method. This method returns a
Class object representing the superclass, or returns null if the class has no
superclass. To identify all ancestors of a class, call getSuperclass
iteratively until it returns null.
The program that follows finds the names of the
The output of the sample program verifies that
the parent of Button is Component,
and that the parent of Component is Object:
java.awt.Component java.lang.Object | |||
|