• 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

parseXxx and valueOf

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am studying from Bert's book on page number 231 there is topic of parseXxx(0 and valueOf(). I have some confusion in it.
In book it is stated that
parseXxx() returns the named primitive.
valueOf() returns a newly created wrapped object of the type that invoked
the method.
and example is

This is fine. But when I use wrapper Class Long instead of primitive long it works fine and vice versa on line 3. If both works fine with both primitive and wrapper then can you please guide me that whats the difference between both??

Thanks,
Awais
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you said:



This line of code only compiles fine in Java 5, which supports auto-boxing and unboxing. There is an unboxing operation happens behind the scene.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic