About 7,780 results
Open links in new tab
  1. Java return Keyword - W3Schools

    The return keyword finishes the execution of a method, and can be used to return a value from a method. More Examples Tip: Use the void keyword to specify that a method should not have a return value:

  2. 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: 1. Methods Returning a Value. For the methods that define a return type, the return statement must be immediately followed by a return value. Example:

  3. 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.

  4. Return Statement in Java - Tpoint Tech

    Feb 12, 2025 · The syntax of a return statement is the return keyword is followed by the value to be returned. The following Java programs demonstrate the use of return statements. The provided code defines a Java class SampleReturn1 that includes a method CompareNum and a main () method to execute the program.

  5. 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.

  6. Return Statement In Java | Syntax, Uses & More (+Code …

    In this article, we will understand the significance of the return statement in Java, its syntax, usage with different return types, and best practices for writing efficient and readable code. Let’s explore how this simple yet powerful keyword enhances the structure and logic of Java programs.

  7. return Statement in Java with Example - javabytechie

    May 28, 2022 · If a method returns a value, then it must use the return statement within the body of the method. The data type of the return value must match the method’s declared return type. Syntax of return statement: return value; Let's understand the use of return statements in Java programs in different scenarios. Example 1 : 'return' Statement in Java

  8. Java return statement with Example | Java return keyword

    Example of java return statement: class ReturnStatement{ public int getSum(int a, int b){ int c = a+b; return c; } public static void main(String args[]){ ReturnStatement obj = new ReturnStatement(); int sum = obj.getSum(10, 20); System.out.println("Sum of a and b is: " …

  9. Return statement in java with example

    In this guide, we will explore the return statement in detail, including its syntax, usage, types, behavior, and various examples. What is the Return Statement? In Java, the return statement is used to exit from a method and optionally return a value. The type of value returned must match the method’s declared return type.

  10. What are Java Flow Control Statements? Break, Continue, Return

    How to Use the return Statement in Java? You can use the return keyword to exit a method at any point. Some key points include: If the method is of type void, then you can write return with nothing else; If the method is of any type other than void, then you must return a variable of that type; Java return Statement Example

  11. Some results have been removed