import java.io.*; import java.lang.Math; class Squr { public static void main () { int m =10,n; double z = 10.4,p; Squr square = new Squr(); p = (double)square.mysqrt(z); n = (int)square.mysqrt(m); System.out.println ("square root of 10 : " + n ); System.out.println ("square root of 10.4 : "+ p ); } double mysqrt (double y) { return Math.sqrt(y); } int mysqrt (int x) { return (int)Math.sqrt(x); } }
该代码正在编译,但是当我们尝试执行该代码时,给出了“线程“ main”中的异常” Java.lang.NoSuchMethodError:main“
该main()函数应这样声明
main()
public static void main(String[] args)