![]() |
The method in Java or Methods of Java is a collection of statements that perform some specific task and return the result to the caller. Every method has a return type that can be differentiated between void and non-void. In this article, we will learn about void and non-void methods. Void Methods in JavaThe void method is a method that does not return any value. It is used to perform some action or operation but does not return any data. Syntax:
Example of Java void MethodJava
Output:Hello, World!
Non-Void Methods in JavaThe non-void method is a method that returns a value of a specific data type.It is used to the perform some calculation or operation and return. Syntax of Java Non-Void
Example of Non Void MethodsJava
Output:The sum of 5 and 9 is: 14
|
Reffered: https://www.geeksforgeeks.org
Difference Between |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |