• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble with returning a string from a method with if statements  RSS feed

 
Jackson Blackwale
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




How come the if statements in my sayYes() method are being skipped? Even if the user input is yes or no, it always returns "Invalid entry"
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you can't reliably compare Strings using "==". Look up the equals() method.
 
Jackson Blackwale
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yeah, thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!