Mots clés : javacastingoperatorsvariable-assignmentassignment-operatorjava
92
short x = 3; x += 4.6;
short x = 3; x = (short)(x + 4.6);
88
byte b = 10; b *= 5.7; System.out.println(b); // prints 57
byte b = 100; b /= 2.5; System.out.println(b); // prints 40
char ch = '0'; ch *= 1.1; System.out.println(ch); // prints '4'
char ch = 'A'; ch *= 1.5; System.out.println(ch); // prints 'a'
78
short x = 3; x += 4.6;
short x = 3; x = (short)(x + 4.6);
64
i += l;
i = (int)(i + l);
51
i = i + (int)l;
i = (int)((long)i + l); // this is what happens in case of += , dont need (long) casting since upper casting is done implicitly.