Math.abs()报告错误:找不到符号(Math.abs() reporting error: cannot find symbol)

编程入门 行业动态 更新时间:2024-10-20 03:15:19
Math.abs()报告错误:找不到符号(Math.abs() reporting error: cannot find symbol)

我是新来的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).

更多推荐

本文发布于:2023-08-07 07:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1463098.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   符号   错误   报告   Math

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!