• Post Reply Bookmark Topic Watch Topic
  • New Topic

methods with parameters  RSS feed

 
kevinn lee
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


what should go in $,$ locations?
(whatever the value or variable(var1&var2) I put there I keep getting the same output.)
 
Pushkar Choudhary
Rancher
Posts: 425
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kevinnn lee wrote:whatever the value or variable(var1&var2) I put there I keep getting the same output.

That's because in the add() method, you are reassigning the values of x and y from var1 and var2 (which are hard coded in the main method). Are you sure you want to do this?

Also, please use code tags when you post any code.
 
kevinn lee
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
So what exactly should go in the $,$ locations?
 
Pushkar Choudhary
Rancher
Posts: 425
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kevinnn lee wrote:So what exactly should go in the $,$ locations?

It doesn't matter! As I said earlier, whatever values you are passing for x and y through the two $ places, are getting overridden in the add() method. So no matter what you put in place of the two $, the output will always be 8.

Read my previous comment again.
 
kevinn lee
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
got it.
thanks a lot
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!