Difference Between Class Variable and Instance Variable
Instance Variable
A class variable without static modifier is called Instance Variable, It is unique to each object(instance) of the class and not shared between the class
Class Variable
Class variable can be declared any where in the class level using keyword static, These variable can only have one value when applied to various object.These variable can be shared by all class member since they are not connected to a specific instance
class Test {
static int count = 0; // Class Variable
int id; // Instance Variable
}
No Comments Yet!!