Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I keep getting null

 
Adam Burda
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I’m working on a homework assignment to make a rock paper scissors game. I have made the main file and now I’m working on the class file. When I try to get it where value == 1 then pick = “Rock” and so on.
Then I want to output what pick is. I get null? Why? Here is my code.




Thank you for any help on this.
 
Tim Moores
Bartender
Posts: 2850
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently the value is not 1. I'd start by examining what value it has, maybe by inserting another System.out.println statement.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DoYourOwnHomework .
dude, Ask question yourself what could be the reason ? and list out your understanding; and not able to figure out ? approach your teacher . your teacher is not able to answer? ... definitely she/he should know about this assignment . in case she/he dont know the clue. come back we will give you a hint

 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check when you're setting the value of pick. In which methods is it set, and when are those methods called.
 
Adam Burda
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im sorry i forgot to enter all of the code the first time. here is the class Game file again with all if statements.

 
Tim Moores
Bartender
Posts: 2850
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You apparently haven't done this yet:
Rob Spoor wrote:Check when you're setting the value of pick. In which methods is it set, and when are those methods called.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic