CoreJava Important Tricks | Tips | Java Linux IDE | Technology Updates | Download Free CoreJava Examples | Video Tuorials | Concepts of Classes

Monday, January 19, 2009

Execution Starting Point

Every java application program starts exection from :

public static void main(String[] arg) method of class.

But if class contains the static block then execution will

begin from there.


Program: StartingPoint.java
public class StartingPoint {

static {
System.out.println("static block executed");
}

public static void main(String[] arg) {
try {
System.out.println("main method executed");
} catch (Exception e) {
e.printStackTrace();
}
}
}

OUTPUT:
static block executed
main method executed

No comments:

Post a Comment

Followers