How to print anything before execution of main method in java?
public class DemoStaticBlock
{
static{
System.out.println("Before Main Class Execution.");
}
public static void main(String args[]){
System.out.println("After Main Class Executed.");
}
}
here static block is always execute before execution of main method.
as we all know that static method is use for calling a method or code without creating its instance.
{
static{
System.out.println("Before Main Class Execution.");
}
public static void main(String args[]){
System.out.println("After Main Class Executed.");
}
}
here static block is always execute before execution of main method.
as we all know that static method is use for calling a method or code without creating its instance.
Comments
Post a Comment