0
Beginner java question(still learning)
why does this code not printing helloworld? (sorry im a real beginner,please forgive me if my code looks idiotic.im trying to play around with the code) class MyClass { static void sayHello() { System.out.println("Hello World!"); } public static void main(String[ ] args) { } static void chicken(){ sayHello(); sayHello(); } }
2 Respuestas
+ 8
The main method is the starting point of the program.
So, start by reading all the code in the main method.
There is no code in the main method.
Therefore, the program is finished and exits successfully.
Try calling the chicken method from the main method.
Like so:
chicken();
+ 3
Exactly like Rrestoring faith said. Or if you want you can call sayHello(); too