wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "strings" Watch "strings" New topic
Author

strings

Ryan Hairyes
Greenhorn

Joined: Oct 26, 2001
Posts: 5
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

Joined: Aug 02, 2001
Posts: 54
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


SCJP, SCWCD
Alex Ku
Ranch Hand

Joined: Jan 15, 2002
Posts: 47
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: strings
 
Similar Threads
String class ?
StringBuffer + equals ????
== works differently with String arguments
which is better to use when comparing Strings
equals n ==