Learning tutorial of array basics in Java
number
Usually, when we deal with numbers, we use the original data types, such as byte, int, long, double, etc.
Example
However, in development, we will encounter situations where we need to use objects instead of raw data types. To achieve this, Java provides wrapper classes for each raw data type.
All wrapper classes (integer, long, byte, double, float, short) are subclasses of the abstract class number.
This packing is handled by the compiler, a process called boxing. Therefore, when a raw data type is used and an object is needed, the compiler puts the raw data into its wrapper class. Similarly, the compiler can take out objects and return them to the original data type. Number is Java Part of Lang package.
Here is an example of packing and unpacking:
This will produce the following results: