here i have written java program
public class Main {
static int i=2000;
public static void main(String[] args) {
System.out.print("value of j inside main "+j);
}
static {
m1();
System.out.print("value of i inside static block "+i);
}
static void m1() {
System.out.print("inside static method");
System.out.print("value of j inside static block "+j);
}
static int j =3000;
}
inside static block, the value of i is printed as 2000, but value of j can't be referred in static block? and value of j printing in m1() method is 0, but j is initialized then why is it printing 0? why j cant be referred in static and it is referred in m1() which is first called by static block? and inside main, value of j is printing as 3000? so can anyone tell me what is wrong i am understanding here?