What is a Void Return Type

A void return type indicates that a method does not return a value.

In Core Java, the void return type is used to indicate that a method does not return any value. When a method is declared with a void return type, it means that the method performs some actions but does not produce a result that can be used or assigned.

Here’s an example of a method with a void return type:

java
public class Example {
// This method has a void return type
public void printMessage() {
System.out.println("Hello, World!");
// This method does not return any value
}
public static void main(String[] args) {
Example example = new Example();
example.printMessage(); // Calling the method that has a void return type
}
}

In the example above, the printMessage method prints a message but does not return any value. The void keyword indicates that the method doesn’t return anything.