• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

parseXxx and valueOf

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic