嗨,我对编码还很陌生,不了解我必须完成的必需任务。如何通过添加main方法来运行以下代码以确保其正常工作?
答案和文档将对您有所帮助,谢谢。
public static boolean approxEqual (double x, double y)
{
//Judge where two numbers are close enough (equal)
final double EPSILON = 1E-10;
if (Math.abs(x-y)<EPSILON)
{
return(true);
}
return(false);
}
答案 0 :(得分:0)
您可以声明一个类,并按如下所示添加main方法
public class Sol {
public static void main(String[] args) {
Sol.approxEqual(1.0,1.2)
}
public static boolean approxEqual (double x, double y)
{
//Judge where two numbers are close enough (equal)
final double EPSILON = 1E-10;
if (Math.abs(x-y)<EPSILON)
{
return(true);
}
return(false);
}
}