IntelliJ Java IDE
The moose likes Beginning Java and the fly likes How to Check null in double Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 1291

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..
[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: 1291

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
 
Threads others viewed
JSTL - c:set - value null
How to we check if primitives like long,int becomes null?
Double is null?
Action form: data getting lost between form submit and setters on ActionForm
struts-2 (set values to action class)
IntelliJ Java IDE