• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [OT] Weird Boolean/ Wrapper class bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] Weird Boolean/ Wrapper class bug


  • Subject: Re: [OT] Weird Boolean/ Wrapper class bug
  • From: "Shravan Kumar. M" <email@hidden>
  • Date: Sat, 21 Nov 2009 07:45:43 -0800 (PST)

Mine: java version "1.5.0_16"


From: David LeBer <email@hidden>
To: Shravan Kumar. M <email@hidden>
Cc: WO Dev Group <email@hidden>
Sent: Sat, November 21, 2009 9:06:22 PM
Subject: Re: [OT] Weird Boolean/ Wrapper class bug


On 2009-11-21, 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");

That makes no sense.

        Boolean b = null;
        if (b != null) {
            NSLog.out.appendln("not null");
        } else {
            NSLog.out.appendln("is null");
        }

Runs fine for me.

Something is hosed with your JVM?

;david

--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site:     http://codeferous.com
blog:     http://davidleber.net
profile:    http://www.linkedin.com/in/davidleber
twitter:    http://twitter.com/rebeld
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >[OT] Weird Boolean/ Wrapper class bug (From: "Shravan Kumar. M" <email@hidden>)
 >Re: [OT] Weird Boolean/ Wrapper class bug (From: David LeBer <email@hidden>)

  • Prev by Date: Re: [OT] Weird Boolean/ Wrapper class bug
  • Next by Date: Re: [OT] Weird Boolean/ Wrapper class bug
  • Previous by thread: Re: [OT] Weird Boolean/ Wrapper class bug
  • Next by thread: Re: [OT] Weird Boolean/ Wrapper class bug
  • Index(es):
    • Date
    • Thread