public static void main(String args[]) {
X x = new X();
Y y = new Y();
Class<?> clObj;
clObj = x.getClass(); // get Class reference
System.out.println("x is object of type: " +
clObj.getName());
clObj = y.getClass(); // get Class reference
System.out.println("y is object of type: " +
clObj.getName());
clObj = clObj.getSuperclass();
System.out.println("y's superclass is " +
clObj.getName());
}
}
The output from this program is shown here:
x is object of type: X
y is object of type: Y
y’s superclass is X
ClassLoader
The abstract classClassLoaderdefines how classes are loaded. Your application can create
subclasses that extendClassLoader, implementing its methods. Doing so allows you to load
classes in some way other than the way they are normally loaded by the Java run-time system.
However, this is not something that you will normally need to do.
Math
TheMathclass contains all the floating-point functions that are used for geometry and
trigonometry, as well as several general-purpose methods.Mathdefines twodouble
constants:E(approximately 2.72) andPI(approximately 3.14).
Transcendental Functions
The following methods accept adoubleparameter for an angle in radians and return the
result of their respective transcendental function:
Method Description
static double sin(doublearg) Returns the sine of the angle specified byargin radians.
static double cos(doublearg) Returns the cosine of the angle specified byargin radians.
static double tan(doublearg) Returns the tangent of the angle specified byargin radians.
418 Part II: The Java Library