Get Started
1054

Q: Why do we need wrapper classes in Java?

  • Show Answer
  • Workspace

Answer :
Explanation :

Dealing with primitives as objects is easier at times. Most of the objects collection store objects and not primitive types. Many utility methods are provided by wrapper classes. To get these advantages we need to use wrapper classes. As they are objects, they can be stored in any of the collection and pass this collection as parameters to the methods.   Features of the Java wrapper Classes: - Wrapper classes convert numeric strings into numeric values. - The way to store primitive data in an object. - The valueOf() method is available in all wrapper classes except Character - All wrapper classes have typeValue() method. This method returns the value of the object as its primitive type.

The Most Comprehensive Exam Preparation Platform

Get the Examsbook Prep App Today