I want to know why the following code prints:
Beta 44
44 44
Please correct me because my analysis is apparently not correct but I cannot figure out why.
b.h gets called first, and it is 44 then b.getH() is called and it prints "Beta 44". So the console prints 44 Beta 44. Why is it not the case?
public class Beta {
public int h = 44;
public int getH(){
System.out.println("Beta "+h);
return h;
}
public static void main(String[] args) {
Beta b = new Beta();
System.out.println(b.h+" "+ b.getH());
}
}