aspose file tools*
The moose likes Beginning Java and the fly likes Numeric Null Comparison Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Numeric Null Comparison" Watch "Numeric Null Comparison" New topic
Author

Numeric Null Comparison

Marc LeClerc
Greenhorn

Joined: May 10, 2007
Posts: 14
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

Joined: Apr 14, 2004
Posts: 10336

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 ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Yes, use "==" for comparison, not '='.


[Jess in Action][AskingGoodQuestions]
Ravikanth kolli
Ranch Hand

Joined: Feb 10, 2008
Posts: 179

are num1 and num2 integers as the topic says numeric null comparision?


-kolli
Marc LeClerc
Greenhorn

Joined: May 10, 2007
Posts: 14
Yes they are integers, the == seemed to have fixed it.

Thanks for not pouncing on the newbie !
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
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.


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
 
 
subject: Numeric Null Comparison