• 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

regarding Wrapper's unboxing

 
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");
 
Your mind is under my control .... your will is now mine .... read this 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