permaculture playing cards*
The moose likes Beginning Java and the fly likes Difference between attribute and parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between attribute and parameter" Watch "Difference between attribute and parameter" New topic
Author

Difference between attribute and parameter

jayant bhoge
Greenhorn

Joined: Nov 29, 2004
Posts: 8
Hi ,
I want to the difference between attribut and parameter and difference between argument and parameter

regards
Jayant
Henrik Engert
Ranch Hand

Joined: Apr 26, 2005
Posts: 70
It is just a definition for what the method takes. You can call them whatever you like. You can say for example a method uses arguments and a user passes parameters.
[ May 03, 2005: Message edited by: Henrik Engert ]

SCJP 5.0, SCWCD
Lionel Badiou
Ranch Hand

Joined: Jan 06, 2005
Posts: 140
Hello Jayant,



As you can see, "parameter" and "argument" are synonymous.
Hope that helps,


Lionel Badiou
CodeFutures Software
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
I've never seen "attribute" used as a synonym for a method parameter/argument. To me, attribute is more akin to a field, though mostly when talking about JavaBeans. My view comes from the dictionary definition of attribute: "A quality or characteristic inherent in or ascribed to someone or something."

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.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
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.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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.

Layne


Java API Documentation
The Java Tutorial
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4445
    
    5

"attribute" and "property" are often used interchangeably.

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)

HTH
[ May 03, 2005: Message edited by: Junilu Lacar ]

Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between attribute and parameter
 
Similar Threads
diff between parameter and attribute
argument or parameter? attribute or property?
How to pass a Post parameter using a link?
request.getAttribute vs request.getParameter
OUT or REF