+ 3
What is static block in java? And can anyone explain the code written in description???
public class Program { static int a=m(); static{ System.out.println("static block"); } static int m() { System.out.println("from m"); return 20; } public static void main(String[] args) { System.out.println("value :"+a); System.out.println("done"); } }
2 Answers