Casting and Ranges of Variables
In programming, casting is the way we convert one data type to another. To cast something from one data type to another, put the data type you want to cast to in parentheses. For instance, you might want to turn a double into an int, or convert an int into a double. Below is an example of casting a byte to a double.
byte number = 5;
System.out.println((double) number); // Remember, whenever you are printing a double that is a whole number, the computer will add ".0" to the end!Output
5.0