Join Examsbook
1081 0

Q: Why do we need wrapper classes in Java?

  • Show AnswerHide 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.

Are you sure

  Report Error

Please Enter Message
Error Reported Successfully