0

If we put print command in second function in the given programming then why does not it execute both methods?

16th Aug 2016, 3:39 PM
Himanshu Mittal
Himanshu Mittal - avatar
6 Réponses
+ 2
because the main method is used as a starting point of a statement in java. which is not in case of other method it tutorial it created method sayhello and used it in main method to execute so the execution is only one time ie in main method. hope it helps you.
16th Aug 2016, 6:58 PM
rajat kumar raicha
rajat kumar raicha - avatar
+ 1
? can you put a bit of code in it. Its hard to understand what you mean.
16th Aug 2016, 3:56 PM
Eric Zeus
Eric Zeus - avatar
0
yes give a explanatory code for it to understand the question?
16th Aug 2016, 3:58 PM
rajat kumar raicha
rajat kumar raicha - avatar
0
class MyClass { static void sayHello() { System.out.println("Hello World!"); } public static void main(String[ ] args) { System.out.print("sayHello"); } } why don't it print both methods
16th Aug 2016, 4:03 PM
Himanshu Mittal
Himanshu Mittal - avatar
0
you are only executing one. you need to call sayHello ();
16th Aug 2016, 4:26 PM
Eric Zeus
Eric Zeus - avatar
0
thank you
17th Aug 2016, 12:31 AM
Himanshu Mittal
Himanshu Mittal - avatar