一尘不染

线程“主”中的异常Java.lang.NoSuchMethodError:主?

java

      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“


阅读 219

收藏
2020-12-03

共1个答案

一尘不染

main()函数应这样声明

public static void main(String[] args)
2020-12-03