For more information, From the IT terminology dictionary that makes you feel like "I understand" and "I don't understand" Please refer to What is the return value . It is illustrated in an easy-to-understand manner.
Here, we will actually explain using a program.
If there is a return valueReturn data typeDeclare with! |
---|
sample1.java
1 public class sample1 {
2 public static void main(String[] args) {
3 double number = average(1,2);
4 System.out.print(number);
5 }
6 static double average(int a, int b) {
7 double x = (a + b) / 2.0;
8 return x;
9 }
10}
Output </ b>
1.5
Recommended Posts