Finding out from what Class an Object is Instantiated

This code example shows how to determine the Class of an Object instance.
There is a method called checkObjectClass which takes an Object as input parameter and first uses instanceof to check whether object is of type Vector or ArrayList.
If none of those classes match, the name of the class is determined by calling the getClass() method which returns the name of the class as a String.
The checkObjectClass() method is called four times with different arguments from the constructor, with an instance of Vector, ArrayList, String and Integer.

The output from the code above looks like this:

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

Please type any questions here.