Next page | Contents page |

Static blocks

Initialisation of static fields can be done in a "static block" which is executed when a class is loaded:

	public class X
	{
		private static Y y = new Y ();
		private static Z z;

		static
		{
			y.loadData ();
			z = new Z ();
			z.init ();
		}

	// . . . etc 

There may be more than one static block in a class.

Next page | Contents page |