Tag: type narrowing

JAVA类型转换

我知道Math.pow方法在java中返回double 。 但是这段代码在我的程序中没有产生任何错误。 编译器是否自动将(int)添加到我的代码中,还是有其他原因? 在代码之前,我声明int sum = 0; 和arg是int的数组。 for(int i=0; i < arg.length; i++) { sum += Math.pow(2, i) * arg[i]; }