我是新来的Java,我试图找出数学函数是如何工作的。 我无法弄清楚我错过了什么。
这是整个程序:
public class Math { public static void main(String args[]) { double x = Math.abs(4); System.out.println(x); } }当我尝试编译它时,jGRASP说:“Math.java:5:错误:找不到符号double x = Math.abs(4);”
I'm new to java and I'm trying to figure out how the Math functions work. I can't figure out what I'm missing.
Here's the entire program:
public class Math { public static void main(String args[]) { double x = Math.abs(4); System.out.println(x); } }When I try to compile it, jGRASP says, "Math.java:5: error: cannot find symbol double x = Math.abs(4);"
最满意答案
你叫你的类Math ,所以内建的java.lang.Math类不能被解析。 所以Java认为你试图调用你自己的不存在的abs方法。
另外调用你的类,或者用完全限定的类名引用Math.abs : java.lang.Math.abs(4) 。
You called your class Math, so the built-in java.lang.Math class can't be resolved. So Java thinks you're attempting to call your own abs method that doesn't exist.
Call your class something else, or refer to Math.abs with a fully qualified class name: java.lang.Math.abs(4).
更多推荐
发布评论