About 16,600,000 results
Open links in new tab
  1. 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:

  2. Java return Keyword - W3Schools

    The return keyword finishes the execution of a method, and can be used to return a value from a method.

  3. java - A Return inside and outside an If Statement - Stack Overflow

    Aug 16, 2013 · If there is a return statement inside an if statement, inside a method (in the Java language), but I add another at the end as a catch-all and to avoid the error, are both return values going to be fired one after the other if the if statement is true? An example: if( 5 > number) { return 5; return 0;

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

  5. Return Statement in Java - Tpoint Tech

    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 …

  6. 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. In such a case, a return statement can be used to branch out of a control flow block and exit the method and is simply used like this:

  7. java return in the if statement - Stack Overflow

    How to use the return to retrieve a value out of an if statement? I don't want to return immediately, just like that: This isn't working for me, because if the return is successful the method returns, but I need to return it and when the return is complete to continue the actions in the method.

  8. return Keyword in Java: Usage & Examples - DataCamp

    Learn how to use the `return` keyword in Java to exit methods and return values. This guide covers syntax, examples, and best practices for effective Java programming.

  9. return Statement in Java with Example - JavaByTechie

    May 28, 2022 · In Java, 'return' is a keyword that is used to return a value after the execution of a method. After executing the return statement, the execution control returns to the code that invoked it. A method can return a single value, a group of values, an object, or a group of objects.

  10. Return Statement In Java | Value, Object, Void With Examples // …

    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.

  11. Some results have been removed
Refresh