File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes what is the difference? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is the difference?" Watch "what is the difference?" New topic

what is the difference?

catherine matthews
Ranch Hand

Joined: Jan 22, 2006
Posts: 78
well i am getting a bit confused here....
what is the differnce between
field, parameter, variable , attribute

from my understanding....
parameter is involved when you want to send a value to a methodcall
variable can be anything parameter, attibute, field... it is more general
filed - is a variable when you assign a value
and attibute is something heneral like a variable as well?
please help me....
[ July 15, 2006: Message edited by: catherine matthews ]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
A variable is a memory location that holds something, either a primitive value like an int or a reference (aka pointer) to an object. The pointer can have a special value of null. The name "variable" came from math and works ok in computing because the value it holds can vary over time, but Java breaks that definition because "final" variables can't vary after initialization.

A parameter is awfully similar. It's declared in the method signature and the memory location is in the stack, but otherwise it's close enough to the same thing.

Field and member or class variable and object attribute all mean the same thing in most conversations. I always liked "attribute" from my earliest OO days, but the Java language spec uses "field".

Local variables declared in a method and parameters declared in the signature are variables but not attributes or fields.

Whew, did that makes sense all together?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Adam Nace
Ranch Hand

Joined: Jul 17, 2006
Posts: 117
There are only minor differences between those terms, and there are also some other terms you will hear used, that were not on that list. Here's a good general list of the terms I use regularly, and how I typically hear them used:


Variables are basically any names that are used to represent values, references or pointers in a program. By this definition, class (static) members, instance members, actual parameters, formal parameters, local variables, and EVEN constants are all variables.


Typically, the word "constant" is used to describe any variable which is define in the following manner:

Although public and static are technically not necessary to ensure that a variable's value cannot change (hence is constant), in java, it is basically a convention that "constant" refers to this type of variable.

Class Members:

Class members are any non-constant variable that belongs to the class, not to any one instance. In java, this is declared using the keyword static. These will also be refered to, therefore, as "static members", "static variables", "static fields", and "class variables."

Instance Members:

An instance member is a variable uniquely belongs to an instance of a class (an object). Each instance will have a unique version of that member. It is any non-static variable declared in the class body, outside of any method or constructor's scope. They are also called fields. Additionally, they are often called properties, especially when they are used in a Java Bean. Usually, if "attribute" does not refer to an object of a class called "Attribute", then "attribute" will indicate an instance member as well. The word "instance" is often ommited, because it is implied if the term "class" is not used to describe the variable.


Parameters are the variables that appear in method signatures. The name used to define each parameter in the method signature is often described with the more qualified name "formal parameters." The variables / values / expressions / etc used when calling the methods are often called the "actual parameters," or the "arguments."

Local Variables:

Local variables are variables that are defined within the body of a method. They are often simlply known as "variables," however it is dangerous to assume that when you hear or see the word "variable" without further qualification, that it is, in fact, a local variable.

More Info:

For further information, and more precise (and possibly more correct, if you believe in such) definitions, you could read through chapter 4 of the Java Language Specification (especially 4.12.3). You can find the JLS on Sun's Java Technology website here: Java Language Spec.

Hope this helps!

- Adam

[ July 17, 2006: Message edited by: Adam Nace ]
[ July 17, 2006: Message edited by: Adam Nace ]
I agree. Here's the link:
subject: what is the difference?
It's not a secret anymore!