Using Methods with Parameters and Return Types in Java


Methods can return data. Define a return type other than void to return values.

Source Code

public static int addNumbers(int a, int b) {
    return a + b;
}
System.out.println(addNumbers(5, 3)); // Call method
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments