Wrapper Classes

In wrapper classes homework help there are many situations, where we need to represent the primitive data types in the form of objects. Some classes have been defined to represent the primitive datatypes in the form of objects. These classes are known as wrapper classes. These classes wrap the concept of the object on the primitive data types.


Uses of Wrapper classes


  1. To represent primitive data types in the form of their equivalent objects.
  2. Wrapper classes have some functions which are useful in representing the contents of a string class object s of a primitive data type in its original form.



Int x=10;

String S1= x+ “ “;  // here S1 is a String class object

S1 = S1. trim();

System.out.println (s1); // 10 will be the output here

Now, this String class object can be converted back into its equivalent primitive data type by using the functions of wrapper classes. Since we have eight primitive data types, obviously we have eight wrapper classes as shown below

Byte, Short, Integer, Long, Float, Double, Character, Boolean.

  1. The wrapper classes are present in the java.lang package
  2. Every wrapper class has two constructors.
  3. One constructor to accept primitive data argument


int x = 10;
Integer i1 = new Integer(x);
·         Another constructor to accept string class object of primitive data types as argument.
Int x = 10;
String s1 = x+ “ “;
Integer i2 = new Integer(s1);



No wrapper class supports a constructor defined to accept zero arguments.

Since there are two constructors available we can pass either the primitive data type or string class object of the primitive data type as argument.

To get back the primitive data types from their equivalent object forms, we have some static and non-static methods.


Wrapper Classes Homework Help

 java homework help java homework assignments from America based Tutorspoint.com java experts