Why JVM doesn't throw any compile time error for not initializing local variable if a local variable is declared like this int a=10,b=3,m;? : I am trying to execute the below code:

public class HelloWorld{

     public static void main(String []args){
         int a=10,b=3,m;
        System.out.println("Hello World "+a+" " + b);
     }
}

I was expecting a compilation error for not initializing local variable 'm' but the program ran successfully and gave me the output. Why is it so ? I was thinking in all the cases if the local variable is not initialized JVM will throw an error.



When I try to execute the code given below

public class HelloWorld{

     public static void main(String []args){
         int a=10,b=3,m;
        System.out.println("Hello World "+a+" " + b + " " +m);
     }
}

Here I am calling the value of 'm' and I am getting error for not initializing local variable.
But why doesn't java throw error in the first case?