Originally posted by zhihui di: what are member variable ? what are instance variable? Is "contructor initialize all the variable" correct?
member variable is one if it is a part of the class memeber like methods. constructors will not initialize these variables. and these variables should be initialized before use. instance variable is one if it is a part of object. it is not declared as static. and all objects contain instance variables. constructors initializes the instance variables if they are not initialized. (except in some cases like given above) [ March 20, 2002: Message edited by: varaku ]
Member variables are variables that are declared at the class level and not within methods or any other block declarations (initializers, etc). Member variables are further separated into two groups: class variables and instance variables. Class variables (or static fields) are those variables declared static. They are initialized when the class itself is initialized and it is the same variable for all instances of the class. Instance variables are those variable not declared static. They are initialized everytime a new instance of the class is created just before the constructor is invoked. Class and instances variables are assigned default values (4.5.5 Initial Values of Variables) when the class, respectively, the instance are initialized. [ March 21, 2002: Message edited by: Valentin Crettaz ]