• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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: 23401
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 ) )

???

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic