• Post Reply Bookmark Topic Watch Topic
  • New Topic

usage a variable of one method as parameter in another method  RSS feed

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
usage a variable of one method as parameter in another method, Is it good idea? What is advantage of this manner?
 
BalaMurali dhar
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use in one method only. You cannot use in another method
 
Stephan van Hulst
Saloon Keeper
Posts: 7969
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't pass variables as arguments to parameters. You pass their values as arguments to parameters.

There is no advantage as much as it's essential. You pass values to methods to make the program work. It's like asking what the advantage of breathing air is.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abalfazl hossein wrote: usage a variable of one method as parameter in another method, Is it good idea? What is advantage of this manner?


yes you can. i do this .... what makes you to ask this question?
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BalaMurali dhar wrote:you can use in one method only. You cannot use in another method
Please explain. That does not sound correct.
 
Stephan van Hulst
Saloon Keeper
Posts: 7969
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think BalaMurali might be referring to using the variable itself in another method, much like pass-by-reference in languages such as C.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it might be possible in pass‑by‑reference.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!