The following piece of code prints out "Counter = 0". I just cant figure this out. I thought it would have printed "Counter = 1". Could someone please explain this?
public class A {
private static int counter;
public A() {
System.out.println("Counter = " + getCounter());
}
public static int getCounter(){
return counter++;
}
public static void main(
String[] args) {
A a1 = new A();
}
}