Return Types in Java

java dev.to

Return Type in Java In Java, the return type means what kind of value a method gives back after it finishes execution. Syntax: returnType methodName(parameters) { // code return value; } 1) Integer Return Type (int) public class Sum { public static void main(String[] args) { Sum num = new Sum(); int result = num.add(5, 3); System.out.println("Sum = " + result); } public int add(int a, int b) { return a + b; } }

Read Full Tutorial open_in_new
arrow_back Back to Tutorials