Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Numeric Null Comparison

 
Marc LeClerc
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following if statement which is gagging on me:



The not null condition works fine, but when trying to see if both are null,
the IDE gives me the following

The operator type && is undefined for the argument type(s) null, boolean


I am VERY new to java and am just trying to tweak some existing code for a vacationing colleague.

Any and all help appreciated.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks suspect:

are those single equals? If they are you are trying to do assignment, not checking their value.
[ April 21, 2008: Message edited by: Paul Sturrock ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, use "==" for comparison, not '='.
 
Ravikanth kolli
Ranch Hand
Posts: 179
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are num1 and num2 integers as the topic says numeric null comparision?
 
Marc LeClerc
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes they are integers, the == seemed to have fixed it.

Thanks for not pouncing on the newbie !
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you're comparisons are faulty, but that will just make it work incorrectly once you get it compiled.

It's not compiling, because you're missing a set of parentheses.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic