Return Types in Java

java dev.to

What is a Return Type? In Java, a return type means the type of value a method gives back after execution. Syntax : returnType methodName() { // code return value; } Types of Return 1. void (No return value) Method does not return anything class Demo { void display() { System.out.println("Hello"); } } Use: When you just want to print / perform action 2. Return with value (int, String, etc.) Method returns a value cl

Read Full Tutorial open_in_new
arrow_back Back to Tutorials