• Post Reply Bookmark Topic Watch Topic
  • New Topic

pass by value  RSS feed

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not understand why this will not run. I get a "cannot find symbol" on the addTwo(value) for class TestTest:

 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question isn't about pass by value. It's about the scope of identifiers. You can't call addTwo that way because it's defined in a different class. When you don't qualify a member name with a reference or class name (a SOMETHING-DOT in front), it assumes you're talking about the current object or class. It's looking for TestTest.addTwo, which clearly doesn't exist. You need a reference to a Test object, since that's where addTwo() is defined. So something like
 
David Starr
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok got it to work now. Thanks.
The code snippet given in the text did not have the "test." as prefix to addTwo(value); [Thus, I was was restricting my code too much.]
And, wow that is a big article on Unit Testing. I have heard of it and heard it is really important. Yet another thing for me to learn.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Starr wrote:And, wow that is a big article on Unit Testing. I have heard of it and heard it is really important. Yet another thing for me to learn.


Yeah, it's good to know about, although not directly relevant to the problem you had here. The forum software automatically creates that link from the word test, so sometimes it looks like we're trying to point you toward something when we're not really.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!