0
The code given below is a program to print hello world! Using methods. The question given below.
class MyClass { static void sayHello() { System.out.println("Hello World!"); } public static void main(String[ ] args) { sayHello(); } } // Outputs "Hello World!" As we say main is the starting point of the program. But sololearn explains the flow of execution as.. prints text first and then called by main function. I want to know the correct flow of execution.
1 Respuesta
+ 1
The main function IS the code so to say. The best practice of organizing functions is to put those that aren't main above main. This is so there is no confusion within the code and the flow to other programmers is neat and cleaner.
The way that you have it is right
sayHello(){}
doSomething(){}
processValue(value){}
main(String[] args){}