Testing if a string is NOT equal to...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vitaminz
    New Member
    • Aug 2008
    • 11

    Testing if a string is NOT equal to...

    Hi, I'm currently coding a Java program for a University coursework, and I'm a little bit stuck.

    How do I find out if a string is NOT equal to a certain value? I know to test if it is equal, you use .equals, but I have no idea how to test if it's not equal to.

    Thanks
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    Use ! to negate a boolean expression, in this case !str1.equals(st r2).

    Comment

    • vitaminz
      New Member
      • Aug 2008
      • 11

      #3
      Wow, thanks for the speedy reply,t hat works perfect :) Thanks again

      Comment

      Working...