Q: Why do we need wrapper classes in Java?
- Show Answer
- Workspace
- Discuss
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.
Similar Questions
Since Nithya and Suganya exchange places, so Rita’s new position is the same as Monika’s earlier position. This position is 17th from the right and 10th from the left. Therefore Number of girls in the row = (16 + 1 + 9) = 26.