方法的定义和调用
定义方法去调用
package com.cai.method;
public class Demo02 {
public static void main(String[] args) {
int max = max(10,20);
System.out.println(max);
}
//定义方法
//比大小
public static int max(int a,int b){
int result = 0;
if (a==b){
System.out.println("没想到两人实力势均力敌");
return 0;//终止方法
}
if(a>b){
result = a; //result 结果
}else {
result = b;
}
return result;
}
}