why this code not execute both print statements | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why this code not execute both print statements

class MyClass { public static void main(String[ ] args) { System.out.println("Hello World"); } } class myclass1{ public static void main (String[] args) { System.out.print("again Hello"); } }

31st Jul 2017, 12:19 PM
Gaurav Shivaji Borade
Gaurav Shivaji Borade - avatar
2 Answers
+ 2
You can only have one psv main method. You're also not calling the method of myclass1. Fix: class myclass1 { public static void mymethod() { System.out.println("again Hello"); } } Then after System.out.println("Hello World"); Do this: myclass1.mymethod();
31st Jul 2017, 1:27 PM
Hassie
Hassie - avatar
0
thank you... ☺👍👍👍👍
8th Aug 2017, 6:52 AM
Gaurav Shivaji Borade
Gaurav Shivaji Borade - avatar