The trick is that length in class Rope is static. That means there is only one copy per class. So rope1 and rope2 point to the same value in Rope.
Urs Waefler wrote:I do not understand properly that RopeSwing has an instance initializer...
and not a static initializer.
Urs Waefler wrote:The following code belongs to the class RopeSwing:
It is never executed, because there is no instance. Correct?
What is about these two statements? I think there are two constructors. Why are the references marked as static?