Void returning no value? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Void returning no value?

so void doesn't return any value, my first thought is that the method is returning a string "hello world" which is in my eyes a value? are strings not values ? or is there somewhere else a value would be returned other than the console?

19th Feb 2017, 3:45 PM
Daniel P Roberts
Daniel P Roberts - avatar
3 Answers
+ 7
Outputting a value to the screen is different from returning it, actually. If the method were to return "Hello world", you'd have to store it somewhere or print it out yourself. Ex: String result = SayHello(); System.out.print(SayHello());
19th Feb 2017, 6:24 PM
Tamra
Tamra - avatar
+ 7
If a value is returned and nothing is done with it, it's just discarded.
19th Feb 2017, 6:43 PM
Tamra
Tamra - avatar
+ 3
So Values cannot be "returned" unless there is somewhere to store it or print out yourself, and you cannot store or print out unless a value is returned ? so is "return" just a description of what's happened after the event ? can you "return" a value and it get stuck because there's nowhere to store it or print out?
19th Feb 2017, 6:35 PM
Daniel P Roberts
Daniel P Roberts - avatar