Java Basic Examples

Convert String to Wrapper Object Example

This example shows how to convert String to wrapper objects like String to Integer object, String to Long object, String to Float object, String to Double object, String to Byte object and String to Short object.

How to convert String to Wrapper objects in Java?

There are a couple of methods using which String can be converted to wrapper class objects.

1) Convert String to Wrapper objects using Wrapper class constructor

Wrapper class provides constructor that accepts String as an argument and returns the wrapper object.


2) Convert String to Wrapper objects using valueOf method of Wrapper class

Use valueOf static method of the respective wrapper class to convert from String to wrapper object as given below.

Please let us know your views in the comments section below.

Want to learn quickly?
Try one of the many quizzes. I promise you will not be disappointed.


About the author



rahimv has over 15 years of experience in designing and developing Java applications. His areas of expertise are J2EE and eCommerce. If you like the website, follow him on Facebook, Twitter or Google Plus.

Add Comment

Your email address will not be published. Required fields are marked *