+ 3

If 'void' in the code means it wont return a value, then how is "Hello World" even used? because System.out.println overides it?

static void sayHello() { System.out.println("Hello World!");

1st Mar 2017, 11:58 AM
Wildman Fizat
Wildman Fizat - avatar
3 Answers
+ 11
As has been pointed out, the string "Hello World" isn't returned by the void function. The function simply printed it without returning it to the call source.
1st Mar 2017, 12:38 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
it doesn't return hello world..it just print hello world. like this: void max (int a, int b) { return (a> b? a:b); } // you can't return value like this
1st Mar 2017, 12:04 PM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar
+ 1
It is actually a good question for the new one. Why the dislikes tho?
1st Mar 2017, 4:58 PM
Tengku Izdihar
Tengku Izdihar - avatar