Sir, as an object, call it in the "object. Method ()" way.
The main method in Java is static, used for the entry of the program, cannot be called in a static method, only static methods can be called. If you want to invoke a static method, you will be the object of the class, calling the non-static method through the object. such as:
public class Squareinttest {
public static void Main (string[] args) {
int result;
squareinttest m = new Squareinttest ();
for (int x = 1; x <= × x + +) {
result = (int) m.square (x);
The Math library also provides a way to calculate the square number
//result= (int) Math.pow (x,2);
System.out.println ("The square of" + x + "is" + result + "\ n");
}
}
A static method for calculating the square number of a custom
public int Square (int a)
{
return a*a;
}
}
Use the object without static. Method calls a function in Java