Staic control
flow in java:------------------------------
Whenever we are
executing java class the following sequence of
Steps will be
executed as the part of static conrol flow
1. Identification
of static members from top to bottom.
2. Execution of static
variable assignments and static blocks from top to bottom.
3. Execution of
main method.
package
staticcontrolflow;
public class
Base {
static int i=10;
static
{
m1();
System.out.println("First
static Block");
}
public static void
main(String[] args) {
m1();
System.out.println("Main
method");
}
public static void
m1()
{
System.out.println(j);
}
static
{
System.out.println("Second
static block");
}
static int j=20;
}
o/p:----------------------------------
0
First static Block
Second static block
20
Main method
No comments:
Post a Comment