Wednesday, April 18, 2007

What is static initializer code?

A class can have a block of initializer code that is simply surrounded by curly braces and labeled as static e.g.
public class Demo{
static int =10;
static{
System.out.println("Hello world');
}
}
And this code is executed exactly once at the time of class load.

0 comments :

 

Disclaimer
Interview Questions On Java,Java EE Copyright © 2017. Reads: best tracker