Java方法02——定义与调用

方法的定义与调用

 

定义与调用

 

例子
 package method;
 
 public class Demon03 {
     public static void main(String[] args) {
 
         int maxnum=max(10,20);
         System.out.println(maxnum);
 
    }
     //比大小
     public static int max(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;
    }
 }
 

 

posted @ 2021-07-17 08:19  时间最考验人  阅读(33)  评论(0编辑  收藏  举报