Fork me on GitHub

找最大值

Posted on 2019-08-23 09:49  攀一座山  阅读(86)  评论(0编辑  收藏  举报
public class ChangeArgs_Exer1 {
    public static void main(String[] args) {
        Count c = new Count();
        System.out.println(c.max(1));
        System.out.println(c.max(5,3,2,6));
    }
}
class Count{
    public int max(int num, int... others){
        int max = num;
        for (int i = 0; i < others.length; i++) {
            if(max < others[i]){
                max = num;
            }
        }
        return max;
    }
}

 

Copyright © 2024 攀一座山
Powered by .NET 9.0 on Kubernetes