How to Return Value in Java


In this example we will show the method to return value in Java.

Source Code

package com.beginner.examples;

public class ReturnValue {

  static String test(String s) {
    return s; // return value
  }

  public static void main(String[] args) {
    System.out.println(test("ok")); // call the method
  }
}

Output:

ok
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments