• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Conflicting statements for arguments and parameters

 
Robin Kumar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am currently done with the first three chapters of the book but i have come across three to four instances where its very confusing to differentiate what exactly is a an argument or a parameter.... kindly read page number 41(1st two lines),46(Definition of argument and parameter) & 249(1st two lines) of the book and please explain what the authors intended to say??
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12015
24
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
umm....WHAT book are you talking about?
 
Robin Kumar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:umm....WHAT book are you talking about?


SCJP Sun Certified Programmer for Java 6-0071591060
 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robin Kumar wrote:I am currently done with the first three chapters of the book but i have come across three to four instances where its very confusing to differentiate what exactly is a an argument or a parameter.... kindly read page number 41(1st two lines),46(Definition of argument and parameter) & 249(1st two lines) of the book and please explain what the authors intended to say??


Ehy Robin,


Parameters: When you declare a method, like for example:



Arguments: However when you call a method, following the previous example it would be:



So basically, parameters are just placeholders for the actual data that are going to be inserted when the method gets called; Arguments, are the data inserted when the method got called.
Hope it cleared up things,

have a nice preparation for the exam!
 
Robin Kumar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nick Widelec wrote:
Robin Kumar wrote:I am currently done with the first three chapters of the book but i have come across three to four instances where its very confusing to differentiate what exactly is a an argument or a parameter.... kindly read page number 41(1st two lines),46(Definition of argument and parameter) & 249(1st two lines) of the book and please explain what the authors intended to say??


Ehy Robin,


Parameters: When you declare a method, like for example:



Arguments: When you call a method, following the previous example it would be:



Hope it cleared up things,

have a nice preparation for the exam!



thanks for your effort but the book says the opposite in many places... kindly refer the pages i have mentioned and explain whether its an error or is there something that i'm not able to understand?
 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robin Kumar wrote:
Nick Widelec wrote:
Robin Kumar wrote:I am currently done with the first three chapters of the book but i have come across three to four instances where its very confusing to differentiate what exactly is a an argument or a parameter.... kindly read page number 41(1st two lines),46(Definition of argument and parameter) & 249(1st two lines) of the book and please explain what the authors intended to say??


Ehy Robin,


Parameters: When you declare a method, like for example:



Arguments: When you call a method, following the previous example it would be:



Hope it cleared up things,

have a nice preparation for the exam!



thanks for your effort but the book says the opposite in many places... kindly refer the pages i have mentioned and explain whether its an error or is there something that i'm not able to understand?


Ehy man, I don't have your book but I can guarantee you that it is in this way.

Check out wikipedia then if still in doubt: http://en.wikipedia.org/wiki/Parameter_%28computer_programming%29#Parameters_and_arguments

Here the wikipedia quote:

These two terms parameter and argument are sometimes loosely used interchangeably, and the context is used to distinguish the meaning. The term parameter (sometimes called formal parameter) is often used to refer to the variable as found in the function definition, while argument (sometimes called actual parameter) refers to the actual value passed. To avoid confusion, it is common to view a parameter as a variable, and an argument as a value.



 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not everyone has the book!

To the extent that there's an official terminology, I'd refer to the Java Language Specification. That uses parameter for the specification:

JLS 8.4.1
The formal parameters of a method or constructor, if any, are specified by a list of comma-separated parameter specifiers. Each parameter specifier consists of a type (optionally preceded by the final modifier and/or one or more annotations) and an identifier (optionally followed by brackets) that specifies the name of the parameter.

and arguments for the actual values:

JLS 15.12
A method invocation expression is used to invoke a class or instance method.

MethodInvocation:
MethodName ( ArgumentListopt )
 
Robin Kumar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you all for your kind support...
 
Robin Kumar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some of the statements of the book are:

"Method arguments are the variable declarations that appear in between the parentheses in a method declaration."

********************************************************

"arguments: The things you specify between the parentheses when you're invoking a method:

doStuff("a", 2); // invoking doStuff, so a & 2 are arguments

parameters :The things in the method's signature that indicate what the
method must receive when it's invoked:

void doStuff(String s, int a) { } // we're expecting two
// parameters: String and int"

********************************************************

"Overloaded methods
❑Must have different argument lists
❑May have different return types, if argument lists are also different
❑May have different access modifiers
❑May throw different exceptions"

********************************************************


"With respect to the method it overrides, the overriding method
❑Must have the same argument list.
❑Must have the same return type, except that as of Java 5, the return type
can be a subclass—this is known as a covariant return.
❑Must not have a more restrictive access modifier.
❑May have a less restrictive access modifier.
❑Must not throw new or broader checked exceptions.
❑May throw fewer or narrower checked exceptions, or any
unchecked exception."

These are some of the confusing statements i found in the book.... can anyone explain what Kathy Sierra and Bert Bates are trying to accomplish??
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic