Every object of a class has all the attributes and methods defined in a class except the static ones. The static variables and methods are not part of the instance of the class. this.
operator is used to refer to the particular instance of the class. To refer to a static variable you need not instantiate the object. You can directly refer to the variable using ClassName.variableName
. So every time you create a new instance of the variable in the code, indx is incremented (starting from 2 since you have post-incremented it).
In order to assign a new incremented value to an object, increment indx and assign it to a variable that is actually a part of the class instance(i.e. a variable that is not static).