difference between ‘static int’ and ‘int’ in java

Take a look here: Understanding Instance and Class Members

When a number of objects are created from the same class blueprint, they each have their own distinct copies of instance variables. (…)

Sometimes, you want to have variables that are common to all objects. This is accomplished with the static modifier. Fields that have the static modifier in their declaration are called static fields or class variables.

Leave a Comment