public class Demo1 {
public static void main(String[] args) {
// 定义两个整数类型变量
int a = 10;
int b = 19;
//调用写好的方法,使用返回值来接收方法返回的结果
int result = compareNum(a,b);
System.out.println(result+"大");
//定义c和d
int c = 99;
int d =23;
int result1 = compareNum(c,d);
System.out.println(result1+"大");
}
public static int compareNum(int a, int b) {
//定义一个结果变量
int c = 0;
//比较a和b的大小,把大的数赋给c;
if(a > b) {
c = a;
}else {
c = b;
}
//方法返回值是c
return c;
}
}