+ 2

Examples of "Void" methods

What makes a method void? I know it's if it doesn't return a value, but what counts as a "value". Is a printed string of text not a value?

24th Jan 2018, 9:29 PM
David Lamar Proctor Land
David Lamar Proctor Land - avatar
1 Answer
+ 2
A value is something that can be stored in a variable. Basically, any information is a value. Printing text does not count as returning a value. It has to have the keyword, “return” followed by a value. If you can do this, it has a return value: someType var = func(param); If not, it does not.
24th Jan 2018, 9:34 PM
Jacob Pembleton
Jacob Pembleton - avatar