• 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

Question about in.next() for a database.

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79239
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic