Determine the Superclass of an Object

To find the superclass of an object we first need to call the getClass() method of the object to return the Class-object.
The Class object then has a method called getSuperClass() which returns another Class object on which the method getName() can be called.
In the example below we call the getSuperClass() method for four different object types: Vector, ArrayList, String and Integer.

The superclass of Vector and ArrayList classes is the java.util.AbstractList class, the String class is derived from the java.lang.Object class and the Integer class is derived from the java.lang.Number class.
The output from the above code looks like this:

Search for more Java info on this site here:
Custom Search

Any thoughts or questions?