方法的定义和调用
1 package method; 2 3 public class Demo02 { 4 public static void main(String[] args) { 5 int max = max(20, 10); 6 System.out.println(max); 7 } 8 //比大小方法 9 public static int max(int num1,int num2){ 10 int result; 11 if (num1 == num2){ 12 System.out.println("num1==num2"); 13 return 0;//终止方法 14 } 15 16 if (num1 > num2) result = num1; 17 else { 18 result = num2; 19 } 20 return result; 21 } 22 }