Questions tagged «type-promotion»

3
为什么“短三十= 3 * 10”是合法的任务?
如果short自动升级为int算术运算,那么为什么是: short thirty = 10 * 3; 对short变量的合法赋值thirty? 反过来,这是: short ten = 10; short three = 3; short thirty = ten * three; // DOES NOT COMPILE AS EXPECTED 以及这个: int ten = 10; int three = 3; short thirty = ten * three; // DOES NOT COMPILE AS EXPECTED …

3
参数中的Java类型提升
我偶然发现了以下片段: public class ParamTest { public static void printSum(int a, double b) { System.out.println("In intDBL " + (a + b)); } public static void printSum(long a, long b) { System.out.println("In long " + (a + b)); } public static void printSum(double a, long b) { System.out.println("In doubleLONG " + (a …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.