我正在关注一本关于java的书,我尝试运行这段代码并在所有数学方法中得到一个符号未找到错误,我虽然Math包含在标准java库中。
public class Math{
public static void main(String[] args){
double root = Math.sqrt(17.0);
double angle = 1.5;
double height = Math.sin(angle);
double radians = Math.toRadians(180);
double degrees = Math.toDegrees(Math.PI);
long round = Math.round(Math.PI * 30);
System.out.println("Root: " + root);
System.out.println("Angle: " + angle);
System.out.println("Height: " + height);
System.out.println("Radians: " + radians);
System.out.println("Degrees: " + degrees);
System.out.println("Round: " + round);
}
}
答案 0 :(得分:4)
但是看,你刚刚覆盖/遮蔽它
public class Math{
这是非常糟糕的做法,但如果你真的想这样做,试试
java.lang.Math.sqrt(...)