File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How do I get Not Equals? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do I get Not Equals?" Watch "How do I get Not Equals?" New topic
Author

How do I get Not Equals?

Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
Ok I understand the equals() but is there a way to check if your string is not equal to something? I take it theres a ! or a false in there somewhere....
Susilo Saja
Ranch Hand

Joined: May 27, 2003
Posts: 91
yes u can use "!" or "== false"
example:
String s1 = "hi";
String s2 = "he";
if (!s1.equals(s2)) {
}
Susilo Saja
Ranch Hand

Joined: May 27, 2003
Posts: 91
Sorry I accidentally click submit before I could finish. Below is my complete reply.
yes u can use "!" or "== false"
example:
String s1 = "hi";
String s2 = "he";
if (!s1.equals(s2)) {
//will go here
}
s1.equals(s2) will return false, and the use of "!" operator is to revert the boolean value (if it's true, it will become false, and the opposite way).
So, !s1.equals(s2) will return true.
The other way is:
if (s1.equals(s2) == false) {
//will go here
}
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi Amy
There are uncountable combinations
Susilo said a part of it.
String s1 = "hi";
String s2 = "he";
if (s1.equals(s2) == false)
if (!s1.equals(s2))
And a part of the following is the sample one.
if(!s2.equal(s1)!=false)
if(s2.equals(s1))!=true)
if (s1!=s2)
if((s1!=s2)!=false)
if ((s1==s2)==false)
if(!(s1==s2))
But you should notice the different between each other
hope this help not confuse


Francis Siu
SCJP, MCDBA
Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
Thanks you two thats cleared it up for me
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I get Not Equals?