Java Create Wrapper Object

Java Create Wrapper Object


Create Wrapper Objects In Java
 
As we have already studied wrapper class in java now we will take a overview again and then we will quickly see example as how to create a object of wrapper in java
● As you know, Java uses primitive types, such as int or double, to hold the basic data types supported by the language.
● Using objects for these basic types would add an unacceptable overhead to even the simplest of calculations.
● Primitive types, rather than objects, are used for these quantities, and for the sake of performance.
● The type wrappers are Double, Float, Long, Integer, Short, Byte, Character, and Boolean, which are packaged in java.lang. These classes offer a wide array of methods that allow you to fully integrate the primitive types into Java’s object hierarchy.
 
Probably the most commonly used type wrappers are those that represent numeric values. These are Byte, Short, Integer, Long, Float, and Double. All of the numeric type wrappers inherit the abstract class Number.
 
Now we will see Examples -
 
Example 1 - 
 
 
Output - 
 
 
Example 2 - 
 
 
Output - 
 
 
Example 3 -
 
 
Output - 
 
 
Above we have seen how can we create a wrapper object like an object of Integer class, Double class etc.