What is the output?
public class Main { static int a; void printA() { System.out.println(a); System.out.println(this.a); } static void hi() { System.out.println("hi"); } public static void main(String[] args) { System.out.println(a); System.out.println(Main.a); System.out.println(new Main().a); new Main().printA(); hi(); new Main().hi(); } }
0 0 0 0 0 hi hi
public class Main { static int a; void printA() { System.out.println(a);/*from w w w . j a va 2 s . c o m*/ System.out.println(this.a); } static void hi() { System.out.println("hi"); } public static void main(String[] args) { System.out.println(a); System.out.println(Main.a); System.out.println(new Main().a); new Main().printA(); hi(); new Main().hi(); } }