• Post Reply Bookmark Topic Watch Topic
  • New Topic

Inheritance issue  RSS feed

 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

the result is 20
I dont know why??
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to try with a pencil and paper. Write down the path through the execution and see if you can't get 20.

You may find it easier if you write it backwards, starting with the 20 and working out the previous step to get there.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
another suggestion would be to put in more print statements.

Print the value of i and v at the very beginning of the add method, and at the very end. and since you have two add methods, make sure you identify which add method is being called/run.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!