+ 13
What is wrapper class in java?
What is wrapper class in java and why is it used?
3 Respostas
+ 16
+ 4
Whenever we say Object oriented programming language, data must be existed in the form of Objects. Concepts like collections in Java expecting data must be in the form of Objects. So in this process we need to convert primitive data types into Objects. To convert primitive data types into objects we need to take support of some classes available from 'java.lang' package known as wrapper class. Some of the wrapper classes are : Byte, Short, Integer, Character,...etc.
+ 2
A Wrapper class is a class whose object wraps or contains a primitive data types. When we create an object to a wrapper class, it contains a field and in this field, we can store a primitive data types. In other words, we can wrap a primitive value into a wrapper class object. Need of Wrapper Classes.
https://www.geeksforgeeks.org/wrapper-classes-java/
n the above code, Integer class is known as a wrapper class (because it wraps around int data type to give it an impression of object). To wrap (or to convert) each primitive data type, there comes a wrapper class. Eight wrapper classes exist in java.lang package that represent 8 data types.
https://way2java.com/java-lang/wrapper-classes/
https://www.javatpoint.com/wrapper-class-in-java