• Post Reply Bookmark Topic Watch Topic
  • New Topic

Inboxing/outboxing clarification  RSS feed

 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • 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:
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!