• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

strings

 
Ryan Hairyes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
How can check to see if something anything but
null? But the catch is that I don't know what
the user will enter. So I can't setup a static
variable for this information. I know you use
the .equals() for comparing strings, but what would I do for not equals?
Thanks.
 
Jason Ford
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ryan Hairyes:

How can check to see if something anything but
null?

Try

Originally posted by Ryan Hairyes:

I know you use
the .equals() for comparing strings, but what would I do for not equals?

If you want to check if two strings are not equivalent, just negate the condition:

In both of these examples, the '!' symbol means 'NOT'.
Hope this helps,
Jason
 
Alex Ku
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Look at the API for equals() method, you will see that its return type is boolean. So, you can do this:
str1.equals(str2) == true
or
str1.equals(str2) == false
or use != instead of ==

kawaii
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic