In Java, does it matter whether a method is defined first or called first?
In the methods tutorial for Java it begins with this code: class MyClass { static void sayHello() { System.out.println("Hello World!"); } public static void main(String[ ] args) { sayHello(); } } // Outputs "Hello World!" It seems as though the method [which they say is System.out.println("Hello World!")] is defined first, and then called with "sayHello();" Am I thinking of that right? But then, later a later example says this: public static void main(String[ ] args) { int res = max(7, 42); System.out.println(res); //42 } static int max(int a, int b) { if(a > b) { return a; } else { return b; } } In this example it seems like the "max()" method is called first by the main, and then defined. So my question is does it matter whether the method is defined or called first? Also am I correct in thinking the main is what calls the method?