0
public class ll {
//    static int x; this doesn't give error
    public static void main(String[] args) {
        int x;
      System.out.println(x); //this gives error "variable x might not have been initialized"
    }
}

Read that the int has default value 0 but when tried consoling got an error whereas the global variable consoled the default value

0 Answers0