Since main is static, it can only call other static methods directly. This is the most common setup for beginner Java programs.
public class Calculator {
public static int multiply(int a, int b) {
return a * b;
}
public static void printResult(int value) {
System.out.println("Result: " + value);
}
public static void main(String[] args) {
int product = multiply(6, 7);
printResult(product);
}
}
All methods are static, so they can call each other freely. If you removed static from multiply, calling it from main would produce a compiler error saying you cannot make a static reference to a non-static method.