手写代码注意点java.lang.Math 相关

1-如果用到了Math的函数,需要手动写上:

import java.lang.Math;

2-求x的y次方,用的是Math.pow(x,y);

注意,返回值是double!!! 不是int, 如果需要转换记得加上强制类型转换。

int result = (int) Math.pow(x,y);

原文地址:https://www.cnblogs.com/frankcui/p/10434225.html