+ 2

Printing 2 lines?

Hey, I tried to code 2 lines beneath each other but it just doesn't seem to work. This is my code I made. public class Testerino { public static void main(String [ ] args) { System.out.println ("Hello darkness"); public static void main(String [] args) { System.out.println ("My old friend"); } }

9th Feb 2018, 6:09 AM
Mr. Cat
Mr. Cat - avatar
5 odpowiedzi
+ 15
//p of public will be in small //there can be only 1 main method ... yes it can be overloaded public class Testerino { public static void main(String [ ] args) { System.out.print("Hello darkness\nMy old friend"); } }
9th Feb 2018, 6:18 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
Why do you have two Main methods? In any case, this way should work: public class Testerino { public static void main(String [ ] args) { System.out.println ("Hello darkness"); System.out.println ("My old friend"); } }
9th Feb 2018, 6:15 AM
Mickel
Mickel - avatar
+ 3
You can't define 2 main method, put the second println immediatly under the first public class Testerino { public static void main(String[] args) { System.out.println("Hello darkness"); System.out.println("My old friend"); } }
9th Feb 2018, 6:18 AM
Leonardo Medai Cossutta
Leonardo Medai Cossutta - avatar
+ 2
@Gaurav yeah I did not realize that it was capitalized
9th Feb 2018, 6:21 AM
Mickel
Mickel - avatar
+ 2
Public class Testerino { public static void main(String[] args) { System.out.println("Hello darkness\nMy old friend"); } }
9th Feb 2018, 6:24 AM
Tim Millar
Tim Millar - avatar