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);"
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)
.