Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (6.1k points)
I have not come across this term of wrapper class before. It is pretty new to me. please tell me what is it?

1 Answer

0 votes
by (11.7k points)

In Java, the Wrapper class is nothing but wrapped around a data type to make them use as objects. Numeric strings can be converted into numeric values using wrapper classes. The valueOf() method is available in all wrapper classes except Character. Wrapper classes are available with typeValue() method. This method returns the value of the object as its primitive type.

Example:

public class Main { 

  public static void main(String[] args) { 

    Integer myInt = 78; 

    Double myDouble = 4.78; 

    Character myChar = 'S'; 

    System.out.println(myInt);

    System.out.println(myDouble);

    System.out.println(myChar);

  }

}

Here, the wrapper class is used instead of the primitive data type to convert data types into objects.

Related questions

0 votes
1 answer
asked Jan 21, 2020 in Java by angadmishra (6.5k points)
0 votes
1 answer
0 votes
1 answer
asked Feb 17, 2021 in Java by sheela_singh (9.5k points)
0 votes
1 answer

Browse Categories

...