Why do we need wrappers like Integer, Boolean for int, boolean in Java? Wrapper classes are used to represent primitive data types as objects. Dealing primitive types as objects is sometimes easier. Many utility methods are available in wrapper classes. As the instances of wrapper classes are created, they can be persisted in the collection classes and pass them to methods as a collection.
|