File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Difference between attributes and parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Difference between attributes and parameters" Watch "Difference between attributes and parameters" New topic
Author

Difference between attributes and parameters

Ravi kapa
Ranch Hand

Joined: Jan 05, 2012
Posts: 31
hi,What is the difference between attributes and parameters???give any good example so that i can understand clearly please......
John Jai
Rancher

Joined: May 31, 2011
Posts: 1372
For me, parameters are passed to a method and attributes store the parameters and act like local variables inside a method.



In the above sample name is the attribute and "Ravi" is the parameter.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 26720
Not convinced. “Attribute” is not a standard word in Java™ jargon. The nearest I can think is that you are talking about the attributes of an object, which means the values of its fields. But some people would use it with a wider meaning, including behavioiur (its methods) in that term too.

In the example shown, name is the method parameter and "Ravi" is an argument passed to that method. In that instance there is specific Java™ jargon.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 2687

Unless you're specifically talking about servlets? There there's a particular distinction. For instance, a request parameter is a read-only string that is passed in from the URL arguments, and a request attribute is a request-scoped object that can be added to the Request object by the servlet (and then accessed elsewhere).

If you're talking in general terms, in object-oriented design (not specifically limited to Java) attributes are the properties of a conceptual class, which (usually) end up corresponding to the fields of the corresponding Java (or whatever language) class.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 26720
I didn’t think we were talking about servlets. I think you, Matthew, and I are in agreement here.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 2687

Campbell Ritchie wrote:I didn’t think we were talking about servlets. I think you, Matthew, and I are in agreement here.


No, I didn't think we were either (it ought to have been in the servlet forum if that was intended!). But I've seen the question asked in that context before quite a few times, so I thought I'd mention it in case.
John Jai
Rancher

Joined: May 31, 2011
Posts: 1372
Campbell Ritchie wrote:In the example shown, name is the method parameter and "Ravi" is an argument passed to that method. In that instance there is specific Java™ jargon.

Yes - I think I made a mistake in my understanding of swapping them both. Thanks Campbell!
 
 
subject: Difference between attributes and parameters
 
Threads others viewed
confused between attributes and parameters
difference between servlets parameters and arguments
Parameters and Attributes
why i can not see any of servlet request parameters ?
Difference between a Parameter and an Attribute
MyEclipse, The Clear Choice