• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Numeric Null Comparison

 
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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE 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 ]
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, use "==" for comparison, not '='.
 
Ranch Hand
Posts: 179
Mac Eclipse IDE Chrome
  • 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 !
 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!