File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What are the three most common approaches for creating wrapper objects Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "What are the three most common approaches for creating wrapper objects" Watch "What are the three most common approaches for creating wrapper objects" New topic
Author

What are the three most common approaches for creating wrapper objects

Sandra Bachan
Ranch Hand

Joined: Feb 18, 2010
Posts: 434
Sierra/Bates, Chapter 3:

For the exam you need to understand the three most common approaches for creating wrapper objects..


However the text only brings up:


primitive xxxValue() - to convert a Wrapper to a primitive

primitive parseXxx(String) - to convert a String to a primitive

Wrapper valueOf(String) - to convert a String to a Wrapper


How does xxxValue() and parseXxx() create a wrapper object? It seems that create a primitive from a Wrapper or String, respectively.

I cannot find anywhere in the book that explicity lists the "three most common approaches for creating wrapper objects"

Also searched google and bing. Please help.


Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Sandra Bachan wrote:
How does xxxValue() and parseXxx() create a wrapper object? .

It wont.
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

In my opinion, if you will know the valueOf() along with the most obvious:



and perhaps explicit and implicit autoboxing



you should be fine for the exam :-)

Cheers!

Edit: thanks Wouter :-)


OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

You're not casting in your example. You're using auto-boxing. A primitive can't be casted because it is not a reference.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: What are the three most common approaches for creating wrapper objects
 
Similar Threads
tricks to wrapper methods
Wrapper again
questions
Common Wrapper Conversion Methods.....???
Doubt in Boolean wrapper object creation