思路:
1.定义一个方法
2.为方法定义两个参数,用于接收两个数字
3.使用分支语句判断两个数字的大小关系进行处理
4.在main()方法中申请定义好的方法(使用常量)
4.在main()方法中申请定义好的方法(使用变量)
public class 带参数方法的输出 {
public static void main(String[] args) {
//使用常量
getMax(10,20);
//使用变量
int a = 10;
int b = 20;
getMax(a,b);
}
public static void getMax(int a,int b) {
if (a>b){
System.out.println(a);
}else {
System.out.println(b);
}
}
}