If you are not familiar with the folk tale The Little Glass Slip , a magical entity does magic that changes from a movie costume to a formal costume. Numerical-Based Casting
When we use casting to change the data type of numeric values, it affects the value of the data.
To cast, we need to use the Casting Operator to notify a setter that we want to create a temporary value that has changed The type of data. Narrow Type Casting
The result will be:
When we have a
double numDouble = 12.99; System.out.println("Double value: " + numDouble); // convert a double to an int rounded to nearest value int numInt = (int) (doubleNum + 0.5); System.out.println("Int value: " + numInt);