Different Classifications of Methods
Let's take a look at the different ways to classify methods in Java.
We'll cover the following...
We'll cover the following...
Void method vs. non-void method
As we discussed in the last lesson, a method may or may not return a value.
-
A void method is a method that does not return anything. It is declared using the keyword
void. -
A method that returns a value can be classified as a non-void method. The return type for such functions can be primitive or reference type.
-
A void method may or may not use the
returnkeyword (lines 4-8). Even if it uses it, it cannot return anything, so it is not followed by any expression. When calling a void method (line 19 ...