Do you understand what
static means exactly with regard to member variables?
It means that there is only one copy of the variable that is shared by all instances of the class, rather than that there is a separate copy of the variable for each instance (which is the case for non-static member variables). So:
y is a static member variable, which is shared by all Thing objects. If you change the value of
Thing.y, as you are doing in lines 22, 23 and 24, then you are changing the one variable that exists that is shared by all Thing objects. It doesn't matter on which instance of Thing you do this (you're doing it for three different Thing instances) - you're still modifing the one shared static variable.
Lines 26 to 29 are just printing the exact same variable four times, so you see the same value four times.
Note that it is bad style to refer to static member variables or static methods via instances of the class;
you should really access them using the classname, not using a specific instance of the class. For example:
Accessing static members through an instance is bad style, because it hides the fact that you're accessing a member that is shared between all instances of the class - it looks like you're accessing a variable of just that instance, which is confusing. (In my opinion, it should not even have been allowed in the
Java language that this is possible - I don't see any use case where you'd ever need to access a static member through an instance).
For more details, see:
Understanding Instance and Class Members in Oracle's Java Tutorials.