Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Check null in double

 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the explanation!
[ July 25, 2006: Message edited by: saif uddin ]
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

primitives have a value always.

..assuming they are definitely assigned.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tony Morris:
..assuming they are definitely assigned.


worth mentioning.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic