Member and instance variables.

Are member and instance variables the same thing? And does anyone know of a good online dictionary/resource of java terms?Cheers.
[144 byte] By [scm9mra] at [2007-9-29 16:23:15]
# 1
I believe a member field (which I guess you can call a variable, although intuitively "variable", to me, suggests a local (stack) variable) can be either an instance field or a class (static) field.But check the language spec, that's the resource you want.
paulcwa at 2007-7-15 14:40:26 > top of Java-index,Archived Forums,Java Programming...
# 2
Instance variable are the variables associated with the particular instance of class (thus static is not instance variable) where as member are simple attributes of the class.....i hope i m clear enough....kk
kaushal_kka at 2007-7-15 14:40:26 > top of Java-index,Archived Forums,Java Programming...
# 3

Member variable and instance variable are terms originating outside of the Java culture. In Java, we have fields - static and non-static fields. We also have members which are either fields, methods or constructors.

The term "member variable" and "instance variable" are generally used interchangeably to mean the same thing as "non-static field".

Chuck

cmccorveya at 2007-7-15 14:40:26 > top of Java-index,Archived Forums,Java Programming...
# 4

Static data belongs to a class, not a particular instance of that class. Every instance of that class shares the static variables. Changes to non-final statics affect all instances.

Each instance can have its own variables. These are NEVER static. Changes to instance variables affect only that instance and no others.

You'll have to get used to different terminology. C++ and other O-O languages sometimes have terms that mingle with Java's. The important thing is the idea. - MOD

duffymoa at 2007-7-15 14:40:26 > top of Java-index,Archived Forums,Java Programming...
# 5

> Instance variable are the variables associated with

> the particular instance of class (thus static is not

> instance variable) where as member are simple

> attributes of the class.....

>

> i hope i m clear enough....

>

> kk

I assume this is what you mean:MyClass myObj = new MyClass();

myObj.myField = 0;

// myObj is an instance variable (instance of class MyClass).

// myField is a member variable (member of a MyClass object).

Ares_Mana at 2007-7-15 14:40:26 > top of Java-index,Archived Forums,Java Programming...
# 6
Could a class variable (static) also be considered a "member variable"? Does the term "member variable" refer to member of an instance, or simply and variable encapsulated in an entity be it class or object?
Ares_Mana at 2007-7-15 14:40:26 > top of Java-index,Archived Forums,Java Programming...
# 7

There is no concept of member-variable in Java. There are three kinds of class members, constructors, methods and fields.

That said, yes, you could say the a class variable is also a member variable even though it is shared among all instances of the class within the scope of the classloader.

Chuck

cmccorveya at 2007-7-15 14:40:26 > top of Java-index,Archived Forums,Java Programming...