If the context is specifically about methods, I would consider attribute more to mean the method's name, visibility scope (public, package, protected, private) and the other modifiers a method can have: static, synchronized, native, etc. In that sense, I view the complete list of parameter types as a single attribute of a method. That list combined with the name and return type make up a method's signature, which really could also be viewed as an attribute itself.
Originally posted by Roger Chung-Wee:
I think of a parameter as being part of a method's API, it's what you declare in the parameter list of the method signature.
To me, the argument is the value passed into the method at runtime, so the arg has to comply with the type of parameter.
I think Roger has given what is typically accepted as the formal definitions of argument and parameter. As other's have posted, the two terms are often used interchangeably, too, unfortunately. I'm not sure what the word "attribute" has to do with this discussion. As far as I know, this is not a commonly used term in the Java programming language.
As for "parameter" vs. "argument", well, there are formal parameters and actual parameters. An "argument" would probably be an actual parameter in most cases that they are referred to as such.
In the above example, s is the formal parameter in the Foo() constructor. At the same time, s becomes the actual parameter (argument) in the call to setProp(). In setProp(), fp is the formal parameter.
In the case of p, it is an instance variable of the Foo class. It can be referred to as a field, a property, or an attribute. You could run into folks who will object to p being called an attribute and would prefer to keep it abstract and say that the Foo class has a Prop attribute that can be accessed via the getProp() method. To these type of folks, p is just an implementation detail. I'm not such a stickler for semantics so I'll just usually go with whatever everybody or most everybody understands (although I will usually object to calling something a Value Object instead of a Data Transfer Object)
[ May 03, 2005: Message edited by: Junilu Lacar ]