Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes I keep getting null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I keep getting null" Watch "I keep getting null" New topic
Author

I keep getting null

Adam Burda
Ranch Hand

Joined: Jul 19, 2011
Posts: 40
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Oct 27, 2005
Posts: 19759
    
  20

Check when you're setting the value of pick. In which methods is it set, and when are those methods called.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Adam Burda
Ranch Hand

Joined: Jul 19, 2011
Posts: 40
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I keep getting null