• Post Reply Bookmark Topic Watch Topic
  • New Topic

I'm an absolute newbie and I was trying to make this code for fun but it's not working  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 
Sheriff
Posts: 4756
133
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There is no keyword or variable called yes. What you probably want is true.


The method next() is problematic in Scanner. Try nextLine().


With nextBoolean() you can only type "true" or "false", not "yes" or "no" or "y" or "n", etc. Just FYI.
 
Marshal
Posts: 58470
178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never write == true or == false which are both poor style and error‑prone (you might write = by mistake). It is
if (birthMatch && swordMatch && bloodMatch) ...
Most people have problems with nextLine if used after nextAnythingElse. As long as you use nextLine before nextAnythingElse you will be all right.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!