• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Inboxing/outboxing clarification

 
Ranch Hand
Posts: 472
Objective C Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can somebody point me on a document explaining this feature?
I use a construction:

It works perfectly when map value 'attendet' is ther, however gives me null ptr exception if there is no value. Ok, probably inboxing happens in this way:

Now I change order:

I'm getting again null ptr exception. Is now outboxing happens, like:

How to figure out a real expression after out/in boxing happen?
Is there a solution without checking for null or using explicit inboxing like:
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, none of the code that you have posted is valid Java code. The single quote is used for characters, and 'attendet' is not a valid character. Anyway, assuming that you meant to use "attendet" instead...

Whenever a primative value is compared with a wrapper object, the wrapper object is *always* unboxed. Regardless, of whether the Boolean object is the first or the second operand in the comparison, the booleanValue() method will be used.

Henry
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic