• Post Reply Bookmark Topic Watch Topic
  • New Topic

argument passing  RSS feed

 
indika ratnayake
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i havent got idea about the argument passing.
 
S Thanigaivel
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Argument is nothing but providing some required information(s) for a method to process.

Consider you have a method called add(int a, int b) { return a+b; }

here a & b are the arguments. For this a and b you should provide some value for the addition to happen.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

Passing arguments is a way to give a method the information it needs to do what it does.

For example, suppose you have a method that factors a number. This method would take an int as an "input" argument. This int is the information the method works with -- in this case, the number it's supposed to factor. Then it might return an array of ints as the "output."

So if you wanted to factor the number 18, you could pass that value as an argument when calling the method...

factor(18);

And this would return an array containing the factors of 18...

{2, 3, 3}
[ June 29, 2006: Message edited by: marc weber ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!