Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

args[ 0 ] != someInput

 
Donald R. Cossitt
buckaroo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does this snippet not do what it seems it should?

TIA
doco
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most of the time you want to use equals() for objects and save == and != for primitives.
 
Donald R. Cossitt
buckaroo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys - oops you too Marilyn I was sure I tried object.equals() and for some reason had a problem but it works fine now. I guess I just wasn't holding my mouth right (jutht a bit of a lithp)
When you get my two 'C' notes I can submit my code - right?
doco
 
Pauline McNamara
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by doco mastadon:

When you get my two 'C' notes I can submit my code - right?
doco

Yep, that's usually how it works. You'll probably hear from someone after your payment gets through the mail room, sent up to sorting, then on to accounting, back to educational administration services... ...assuming, of course, that the computers aren't down today.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course it will also have to be spent so there's no way to get it back to you
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic