找最大值

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

猜你喜欢

转载自www.cnblogs.com/panyizuoshan/p/11398230.html