Mega Code Archive

 
Categories / Java Tutorial / Data Type
 

Narrowing conversion with information loss

Narrowing conversion may incur information loss, if the converted value is larger than the capacity of the target type. In the following conversion, there is some information loss because 9876543210L is too big for an int. public class MainClass {   public static void main(String[] args) {     long a = 9876543210L;     int b = (int) a;     System.out.println(b);   } } 1286608618