打印最大值

package com.guoba.method;

public class Demo05 {
    public static void printMax(double ... numbers) {
        if (numbers.length == 0){
            System.out.println("NO argument passed");
            return;
        }
        double result = numbers[0];

        //排序
//        for (int i = 1;i < numbers.length;i++){
//            if (numbers[i] > result){
//                result = numbers[i];
//            }
//        }
        System.out.println("The max values is " + result);
    }

    public static void main(String[] args) {
        Demo05 demo05 = new Demo05();
        demo05.printMax(6,4,5);
    }

}
posted @ 2021-12-14 09:30  锅巴编程  阅读(45)  评论(0编辑  收藏  举报