Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method arguments

 
Kendall Ponder
Ranch Hand
Posts: 205
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since java always passes a copy of the argument wouldn't both of these methods behave identically?



When I use int x as an argument for m2, I am declaring a local int variable x which will store the value which is passed to the method. Correct?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can indeed consider a method parameter as a local variable. So both m1 and m2 define a local variable x.
But Oracle clearly makes a distinction between parameters and local variables. And here you'll find a similar question.

Hope it helps!
Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic