未找到数学方法符号

时间:2016-10-05 00:26:03

标签: java math methods

我正在关注一本关于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);
    }
}

1 个答案:

答案 0 :(得分:4)

但是看,你刚刚覆盖/遮蔽它

public class Math{

这是非常糟糕的做法,但如果你真的想这样做,试试

java.lang.Math.sqrt(...)