
Returning a Value from a Method (The Java™ Tutorials - Oracle
Within the body of the method, you use the return statement to return the value. Any method declared void doesn't return a value. It does not need to contain a return statement, but it may do so.
Java return Keyword - W3Schools
The return keyword finishes the execution of a method, and can be used to return a value from a method.
Java return Keyword - GeeksforGeeks
Jan 2, 2025 · return keyword in Java is a reserved keyword which is used to exit from a method, with or without a value. The usage of the return keyword can be categorized into two cases: Methods returning a value; Methods not returning a value; 1. Methods Returning a Value
java - What does it mean to return a value? - Stack Overflow
May 1, 2013 · Returning a value is a way for methods to talk to each other. int value = 5 + method2(5); System.out.println(value); return param + 5; This will print 15 (5 gets sent to method2, which adds 5 to it and returns the result to method1, which …
How do I return a value from a Java function? - Stack Overflow
Dec 28, 2016 · In order to make use of a return a value from a function you must assign it to a variable or use it as a test condition, etc. if(returnTen(mystery, subend, result, success) > 0){ System.out.println("returnTen returned an int value"); }
How to use return value from method in Java? - Stack Overflow
Mar 11, 2015 · I want to use the return value from a member function by storing it into a variable and then using it. For example: public int give_value(int x,int y) { int a=0,b=0,c; c=a+b; return c; } pu...
How to Return Multiple Values From a Java Method - Baeldung
May 11, 2024 · In this tutorial, we’ll learn different ways to return multiple values from a Java method. First, we’ll return arrays and collections. Then we’ll demonstrate how to use container classes for complex data, and learn how to create generic tuple classes. Finally, we’ll illustrate how to use third-party libraries to return multiple values. 2.
How to return a value in Java - JavaPointers
This article will help you on how to return a value in java language using the return keyword. Returning a value means storing the evaluated variable and return its data to the method where it was called.
Java return Statement - Java Guides
The return statement in Java is a control flow statement used to exit a method and optionally return a value to the caller. It plays a critical role in methods by indicating the end of the method's execution and providing a mechanism to pass results back to the method caller.
Return Statement in Java - Tpoint Tech
Feb 12, 2025 · In Java programming, the return statement is used for returning a value when the execution of the block is completed. The return statement inside a loop will cause the loop to break and further statements will be ignored by the compiler. The return statement is a fundamental part of Java programming.
- Some results have been removed