+ 1

What is wrong with this code? I want it to output the text "Hello world" and then the "who are you". I am so new to this whole c

class MyClass { static void sayHello() { System.out.println("Hello World!") class Metall { static void hellNo() { system.out.println("who are you"); } public static void main(String[ ] args) { sayHello(); sayHello(); sayHello(); } public static void main(String)[ ] args) { hellNo(); }

1st Dec 2016, 7:03 AM
Tristan
Tristan - avatar
4 ответов
+ 11
class MyClass { static void sayHello() { System.out.println("Hello World!"); } static void hellNo() { System.out.println("who are you"); } public static void main(String[ ] args) { sayHello(); sayHello(); sayHello(); hellNo(); } } This will print 3 times hello world. You made some mistakes. First you cannot have 2 main(String[] args) in the same class. So you would have to move one in your first class. You also forgot a semicolon and you wrote system instead of System with capital S.and you forgot to close braces on first method. If you want to print hello world just once Saeed go is good !
1st Dec 2016, 7:31 AM
R2-D2
R2-D2 - avatar
+ 4
public class Program { static void sayHello() { System.out.println("Hello World!") ; } static void hellNo() { System.out.println("who are you"); } public static void main(String[] args) { sayHello(); hellNo(); } }
1st Dec 2016, 7:24 AM
Saeed
Saeed - avatar
+ 1
there are multiplemain methods here you can call both sayHello and no hello. in same block inside
1st Dec 2016, 7:58 AM
Sandeep Chatterjee
0
Yo mustn't create other main method !Never!
1st Dec 2016, 11:33 PM
Aly Lema