When to use static variables/methods and when to use instance variables/methods in Java? [closed]

At novice level :

Use instance variables when : Every variable has a different value for different object. E.g. name of student, roll number etc..

use static variables when : The value of the variable is independent of the objects (not unique for each object). E.g. number of students.

Leave a Comment