I declared the int previously, and set it as "none". Inside the object, I also set MonsterName as none, or it would say MonsterObject.java:17: error: not a statement.
Okay, that got rid of the compiler error. I made a setter and getter method for the object to return the MonsterName:
Everything compiles correctly, but as the output I'm getting "none" after the name ( output: Name none )
I really need help, thank you for your time! I removed some irelevant code pieces, but if you want the full code, just tell me.
You have the assignment backwards. You need to make the variable being assigned to on the Left side, and the one being assigned from on the Right. This is a common mistake, and one I like to prevent by making the parameters to methods final:
If you do that then the compiler complains and you know exactly where the problem is!
Joined: Mar 11, 2013
Thanks, you guys are great! So the parameter always goes after?
Joined: Feb 10, 2001
So the parameter always goes after?
don't remember it this way, remember that for assignment operator (=) the left side variable receives the value from right side variable (or constant or literal ).