void vs void in java code example

Example: 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.

Tags:

Java Example