• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is There a Opposite to .equal() ?

 
Sheriff
Posts: 440
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Say I compare two objects, Obj1 and Obj2 with .equals().
<pre>
if( Obj1.equals(Obj2) )
{
// do something
}
</pre>
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:
<pre>
if( Obj1.equals(Obj2) )
{
// do nothing
}
else
{
// do what is desired
}
</pre>
Thanks in advance,
Matt
 
Trailboss
Posts: 23778
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about
if ( ! obj1.equals( obj2 ) )

???

 
reply
    Bookmark Topic Watch Topic
  • New Topic