AIM: Write a static block which will be executed before main() method in a class
StaticMain.java
class StaticMain { static { System.out.println("I'm Static Before Main Method"); } public static void main(String arg[]) { System.out.println("I'm Main Method"); } static { System.out.println("I'm Static After Main Method"); } }
Note: Please Try to Yourself.
Happy Coding :)
0 Comments
Post a Comment