FileDocCategorySizeDatePackage
ClassKeyword.javaAPI DocExample782Sat Nov 25 12:55:24 GMT 2000None

ClassKeyword.java

import java.util.*;
/**
 * Show the Class keyword and getClass() method in action.
 * @author Ian F. Darwin, ian@darwinsys.com
 * @version $Id: ClassKeyword.java,v 1.2 2000/11/25 17:55:24 ian Exp $
 */
public class ClassKeyword {
	public static void main(String[] argv) {
		//+
		System.out.println("Trying the ClassName.class keyword:");
		System.out.println("Object class: " + Object.class);
		System.out.println("String class: " + String.class);
		System.out.println("Calendar class: " + Calendar.class);
		System.out.println("Current class: " + ClassKeyword.class);
		System.out.println();

		System.out.println("Trying the instance.getClass() method:");
		System.out.println("Robin the Fearless".getClass());
		System.out.println(Calendar.getInstance().getClass());
		//-
	}
}