FileDocCategorySizeDatePackage
StaticIniDemo.javaAPI DocExample1076Sun Feb 08 21:33:54 GMT 2004None

StaticIniDemo

public class StaticIniDemo extends Object
Show static initializers. These are run when the class is loaded. If you run the main program here, you will see the static initializer before the "About to load class", since the class is loaded before main gets run. If you copy the guts of main into another class, the messages will come out in the "expected" order.
author
Ian F. Darwin, http://www.darwinsys.com/
version
$Id: StaticIniDemo.java,v 1.5 2004/02/09 03:33:54 ian Exp $

Fields Summary
Constructors Summary
public StaticIniDemo()
A constructor -- called when object is instantiated.

		System.out.println("In static initializer");
	
		System.out.println("In Constructor");
	
Methods Summary
public static voidmain(java.lang.String[] a)

		try {
			System.err.println("About to load class");
			Class c = Class.forName("StaticIniDemo");
			System.err.println("About to construct instance");
			Object sd = c.newInstance();
			System.err.println("Object is " + sd);
		} catch (Exception e) {
			e.printStackTrace();
		}