伙计们。我已经尝试解决这个问题有一段时间了,但我似乎无法弄清楚问题出在哪里。我做了一些研究,但对其他人来说,这只是大写拼写错误之类的东西。我没有和我一起剪。完整代码如下:
import java.lang.Math;
public class Threesix_RasmusDS
{
public static void smallerAbsVal()
{
int a = 4;
int b = 9;
System.out.println(Math.abs(a, b));
System.out.println(Math.min(a, b));
}
//End of smallerAbsVal
}
//End of class
最佳答案
根据 javadoc,Math#abs
仅接受一个参数,因此它必须是 Math.abs(a)
或 Math.abs(b)
。如果您正在寻找最小的绝对值,那么那就是
System.out.println(Math.min(Math.abs(a), Math.abs(b)));
关于Java(初学者): Cannot find symbol in Math class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18578571/