Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about in.next() for a database.

 
David Spurgeon
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

After creating the scanner console and such, this is my code. I want the user to enter one of two options or it will generate an error message. However, I ALWAYS get the error message, no matter what I enter.



Output:

Enter the student's status (type either resident or nonresident)
resident
resident
Invalid status. Entry must be either resident or nonresident. Enter again

I'm sure this is some dumb error (of course), but I don't know what it is. What am I missing?

Thank you.
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is what comes from using == and != to test reference types for equality. Try the equals method.
 
David Spurgeon
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah! I figured out what you mean. Took a little bit to determine how to use equals() to verify INequality, but it worked.
Thank you for the quick and helpful answer!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic