You're not pasting the real code, I don't think. I suspect you're just getting 
screwed by autoboxing in whatever code you're not showing. If you have:

Boolean a = null;
boolean b = a;

That will result in a NPE as auto-unboxing attempts to unbox a into a boolean, 
which throws a NPE. Somewhere in the code you didn't include is an unbox into a 
boolean (little b) of your null Boolean.

So, for instance:

Boolean a = null;
if (a) {
}

will NPE. Look more closely at the exact code, specifically the line of code 
that actually failing, and make sure you're not getting an unbox.

ms

On Nov 21, 2009, at 10:23 AM, Shravan Kumar. M wrote:

> Hello Group,
> 
> Boolean a = null;
> if(a != null)
>       System.out.println("s");
> else 
>       System.out.println("n");
>       
> ----------
> Above code block raises NullPointerException, where as below one runs 
> successfully!!! Same is the case with any wrapper class (Integer, Long, ...).
> *Its wondering what it makes difference in checking (a != null)  and (a == 
> null)? Its just an Object check rt!*
> 
> Exact exception: java.lang.NullPointerException at booleanValue()
> ----------
>       
> Boolean a = null;
> if(a == null)
>       System.out.println("s");
> else 
>       System.out.println("n");
> 
> Thank You,
> Shravan Kumar. M
> --------------------------------
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/mschrag%40mdimension.com
> 
> This email sent to [email protected]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to