W
widening conversion

What happens when a value of one type is converted to a wider type—that is, a type with a wider range of possible values. Converting from a short to an int is a widening conversion; converting from a char to a byte is not. The Java runtime knows that your variable couldn't suffer any loss of data by putting its value in a container bigger than the one it already has. For this reason, widening conversions happen automatically. You can lose data when performing a widening conversion that is done automatically. Numerical range is the important thing. Example (float's numerical range encompasses long's, but long (64-bits) can hold more digits than float (32-bits)):

 public class ConversionTest { public static void main(String[] ...

Get Java Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.