方法的定义与调用

 

定义与调用

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;
    }
 }
 

 

相关文章:

  • 2022-01-09
  • 2021-11-12
  • 2021-08-26
  • 2022-01-05
  • 2022-02-13
  • 2021-05-23
猜你喜欢
  • 2022-02-25
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
  • 2021-04-29
  • 2022-01-10
  • 2021-04-29
相关资源
相似解决方案