• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I keep getting null

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic