About 27,100,000 results
Open links in new tab
  1. Returning a Value from a Method (The Java™ Tutorials - Oracle

    You declare a method's return type in its method declaration. Within the body of the method, you use the return statement to return the value. Any method declared void doesn't return a value.

  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 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:

  4. Return statement in Java methods - Stack Overflow

    Feb 1, 2014 · Return statements stop the execution of a method and return the final value (or nothing in case of void methods). Execution continues at the place that called the method. The value you returned is used in place of the method call and calulation can continue.

  5. Returning object from a Java method - Stack Overflow

    Sep 29, 2014 · "In order to return an object from a Java method, you must first declare a variable to hold a reference to the object." for example: So in this case, Ball is a variable that is a reference to the object. Correct? redBall is a reference to the object created by the new Ball("red") statement. No redBall is the variable and instance of a Ball.

  6. Java Methods - W3Schools

    A method must be declared within a class. It is defined with the name of the method, followed by parentheses (). Java provides some pre-defined methods, such as System.out.println(), but you can also create your own methods to perform certain actions:

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

  8. Returning Values From Methods (Java) – GeekTechStuff

    Jun 9, 2019 · Java Return Method The above example will return the integer 4 to the main method. The below methods so various examples of the returns including how values can be passed into a method and a new value returned (see addNumbers on the below image).

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

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

Refresh