wood burning stoves 2.0*
The moose likes Java in General and the fly likes Difference between attributes and parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
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: 86
hi,What is the difference between attributes and parameters???give any good example so that i can understand clearly please......
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
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: 37970
    
  22
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: 4343
    
    8

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: 37970
    
  22
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: 4343
    
    8

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
Bartender

Joined: May 31, 2011
Posts: 1776
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between attributes and parameters
 
Similar Threads
Difference between a Parameter and an Attribute
confused between attributes and parameters
difference between servlets parameters and arguments
Parameters and Attributes
why i can not see any of servlet request parameters ?