The question says create a method and use the method to print "hello world" in java. I need help please guys | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

The question says create a method and use the method to print "hello world" in java. I need help please guys

Java methods creation

27th Mar 2021, 7:36 PM
Mubarak Usman Gidado
Mubarak Usman Gidado - avatar
4 Answers
+ 3
Moubaraq Uthman Method should have return type. So here we can use return type void which not return anything. But you can call method to display results.
27th Mar 2021, 8:18 PM
A͢J
A͢J - avatar
+ 3
Moubaraq Uthman This is not right. Create a method and print Hello World in this method and call the method in main method. So it should be like static void print() { System.out.println("Hello World"); } public static void main (String [] args) { print (); }
27th Mar 2021, 8:05 PM
A͢J
A͢J - avatar
0
Is it correct if i write something like this Public lecture (){ } Public static void main (string [ ] args){ System.out.print("hello world") }
27th Mar 2021, 7:39 PM
Mubarak Usman Gidado
Mubarak Usman Gidado - avatar
0
What about something like this Public lecture (){ System.out.println("hello world") }
27th Mar 2021, 8:15 PM
Mubarak Usman Gidado
Mubarak Usman Gidado - avatar