+ 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"); } }

25th Mar 2019, 3:44 AM
Kushang Shah
Kushang Shah - avatar
1 Resposta
18th Sep 2019, 10:49 AM
Danijel Ivanović
Danijel Ivanović - avatar