Method Demo02

发布时间 2023-10-22 12:57:57作者: 宁宁宁宁宁宁宁宁

package com.chen.method;

public class Demo02 {
public static void main(String[] args) {
double sum = sum(1.0, 1.0);
System.out.println(sum);

}
//比大小
public static double sum(double a,double b) {
double result = 0;

if (a == b) {
System.out.println("a==b");
return 0;//终止方法
}

if (a > b) {
result = a;
} else {
result = b;
}
return result;
}

//比大小
public static int sum(int a,int b){
int result = 0;

if(a==b){
System.out.println("a==b");
return 0;//终止方法
}

if(a>b){
result = a;
}else {
result = b;
}
return result;
}
}