Here are some tips for finding solutions to java problems about “difference between void and non void methods in java” Code Answer. We are going to list out some java programming problem, you can find the solution for your programming question if you get stuck in coding. Getting stuck in programming is quite normal for all the developers. Most of the beginners and even experienced programmers take help from some resources but that doesn’t mean they are dumb or bad programmers. Below are some solution about “difference between void and non void methods in java” Code Answer.
difference between void and non void methods in java
-void : does not return any value.
The "void" return type means that
this method doesn't have a return type.
In an application, this approach
may be used to print runtime
specific messages on the console. Exp: "setter" in encapsulation.
-non-void: MUST return a Value.
(Data type needs to be same with return-type)
This means that you can use the
returned value in your code for
further processing. I guess good
examples of such methods
are "getter" in encapsulation.