aspose file tools*
The moose likes Beginning Java and the fly likes How to Check null in double Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to Check null in double" Watch "How to Check null in double" New topic
Author

How to Check null in double

Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

hi all
can any body body tell me how i check a null value in double type variable..?

double value

if(value (???) null)

thanx



[ April 08, 2006: Message edited by: saif uddin ]

Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
you can not check a primitive (double, float, long, int, char, short, byte, boolean) datatype for null.

primitives have a value always. you can only check references to Objects for null. there is a wrapper Object for each of the primitives (Double, Float,, Long, Integer, ...) if you use these, then you can check for null.

if you use java 1.5/5.0 then you should read about "autoboxing/unboxing", a feature which allows you to write code like this:



here primitives and wrapper objects are mixed.
of course there are a some rules when/how autoboxing happens (e.g. what if you assign null to a primitive and so on). and it's important you understand these...


pascal
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Thanks for the explanation!
[ July 25, 2006: Message edited by: saif uddin ]
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608

primitives have a value always.

..assuming they are definitely assigned.


Tony Morris
Java Q&A (FAQ, Trivia)
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Tony Morris:
..assuming they are definitely assigned.


worth mentioning.
 
 
subject: How to Check null in double