Here i is a class variable, are we allowed to change value assigned to class varaible ?
posted 5 years ago
You can reassign any variable that is not marked "final". Note however that what you have in your example is NOT a class variable (marked with "static"). Class variables only exist once, regardless how many object instances you create. So if one object changes the value, all other instances will see the change. Instance variables (such as your variable "i") on the other hand exist for each object instance, so a change in one instance won't be noted in any other instance.