The moose likes Java in General and the fly likes Is There a Opposite to .equal() ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Is There a Opposite to .equal() ?" Watch "Is There a Opposite to .equal() ?" New topic

Is There a Opposite to .equal() ?

Matt Midcap

Joined: Jan 07, 1999
Posts: 440
Say I compare two objects, Obj1 and Obj2 with .equals().
if( Obj1.equals(Obj2) )
// do something
This works fine and dandy. But what if I want to do the opposite, "not equals"? I have looked at the API and was unable to find anything like ".notEquals()". So what I what I did (I was in a hurry) was:
if( Obj1.equals(Obj2) )
// do nothing
// do what is desired
Thanks in advance,

Best Regards,<br />Matt Midcap
paul wheaton

Joined: Dec 14, 1998
Posts: 20494

How about
if ( ! obj1.equals( obj2 ) )


permaculture Wood Burning Stoves 2.0 - 4-DVD set
It is sorta covered in the JavaRanch Style Guide.
subject: Is There a Opposite to .equal() ?
Similar Threads
Need Help For Exam .
question concering hashCode(), equals() and operator ==
equals() and ==
Equals and ==
Treeset ordering