Worked example
public class Main {
static void sayHi() { // the method: declared next to main
System.out.println("Hi!");
}
public static void main(String[] args) {
sayHi(); // main calls it
sayHi(); // and can call it again
}
}
Two things to notice. The word static is what lets main call the method directly — treat it as part of the recipe for now. And a method does nothing until it is called: declaring sayHi prints nothing by itself.
The order does not matter: the method may be written above or below main, and the program behaves the same.