Normally, when we work-related with Numbers, we use primitive data varieties such as byte, int, long, double, etc.

You are watching: The numeric wrapper classes are subclasses of number.

### Example

int ns = 5000;float gpa = 13.65f;double mask = 125;However, in development, we come throughout situations wherein we need to use objects instead of primitive data types. In stimulate to accomplish this, Java provides wrapper classes.

All the wrapper classes (Integer, Long, Byte, Double, Float, Short) are subclasses the the abstract course Number.

The thing of the wrapper course contains or wraps its particular primitive data type. Convert primitive data species into thing is referred to as **boxing**, and this is taken treatment by the compiler. Therefore, while utilizing a wrapper class you simply need to happen the worth of the primitive data form to the constructor that the Wrapper class.

And the Wrapper object will certainly be converted back to a primitive data type, and this process is called unboxing. The **Number** course is part of the java.lang package.

Following is an example of boxing and also unboxing −

### Example

Live Demopublic class Test public revolution void main(String args<>) creature x = 5; // boxes int to an Integer thing x = x + 10; // unboxes the Integer come a int System.out.println(x); This will produce the following result −

### Output

15When x is assigned an essence value, the compiler crate the integer since x is integer object. Later, x is unboxed so that they can be added as one integer.

## Number Methods

Following is the perform of the instance methods the all the subclasses the the Number class implements −

Sr.No.Method & Description1 | xxxValue() Converts the value of this Number thing to the xxx data form and return it. |

2 | compareTo() Compares this Number object to the argument. |

3 | equals() Determines even if it is this number thing is equal to the argument. |

4 | valueOf() Returns one Integer object holding the worth of the specified primitive. |

5 | toString() Returns a String object representing the worth of a mentioned int or Integer. |

6 | parseInt() This an approach is provided to obtain the primitive data type of a certain String. |

7 | abs() Returns the absolute worth of the argument. |

8 | ceil() Returns the the smallest integer that is higher than or same to the argument. Reverted as a double. |

9 | floor() Returns the largest integer the is much less than or equal to the argument. Reverted as a double. |

10 | rint() Returns the integer that is closest in worth to the argument. Returned as a double. |

11 | round() Returns the closest long or int, as shown by the method"s return type to the argument. |

12 | min() Returns the smaller sized of the two arguments. |

13 | max() Returns the bigger of the 2 arguments. |

14 | exp() Returns the base of the natural logarithms, e, to the power of the argument. |

15 | log() Returns the natural logarithm the the argument. |

16 | pow() Returns the worth of the first argument elevated to the power of the second argument. |

17 | sqrt() Returns the square root of the argument. |

18 | sin() Returns the sine of the specified double value. |

19 | cos() Returns the cosine of the specified dual value. |

20 | tan() Returns the tangent the the specified double value. |

21 | asin() Returns the arcsine that the specified twin value. |

22 | acos() Returns the arccosine the the specified twin value. |

23 | atan() Returns the arctangent the the specified dual value. |

24 | atan2() Converts rectangular works with (x, y) come polar coordinate (r, theta) and also returns theta. |

25 | toDegrees() Converts the dispute to degrees. |

26 | toRadians() Converts the discussion to radians. |

27 | random() Returns a random number. |

## What is Next?

In the next section, we will certainly be going with the Character course in Java. You will be learning exactly how to use object Characters and also primitive data form char in Java.