Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding Wrapper's unboxing

 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
As we know that-- True,TRUE are wrapper Boolean values.


First see code:
boolean b=TRUE;//line 1

Boolean b2=true; //line 2

Now my question is that as in line 2, true value (i.e. primitive value) boxed into wrapper value and then assign to wrapper variable b2.But why not in line 1,True value (that is wrapper value) unboxed to primitive value and then assign to primitive variable.
 
Pranav Bhatt
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the Boolean object but intead you have use it with refence of class as-:

boolean b=Boolean.TRUE; instead of boolean b=TRUE;

Now it will work out fine
 
Dean Jones
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
boolean b=True, or boolean b=True does not compile as it they are not recogninized by the compiler.
You can try,
Boolean b2=new Boolean("TRUE");
Boolean b3=new Boolean("True");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic