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);
}
}
This code is compiling but when we try to execute it it giving " Exception in thread "main" Java.lang.NoSuchMethodError: main "
Your main() method should be like that
or
or
The
main()
function should be declared like thisJava is a strong type language. You must declare the method in a given way. The right way to define the main() method is:
The correct method signature for the
main
method in Java is:Simply add the missing arguments in you method declaration and it should work.
It looks like you've not defined your main method with the correct signature. It should be:
Try that: