JAVA-数组获取最大值

package com.itheima;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

public class shuzudemo2 {

    public static void main(String[] args) {
        //数组定义
    int[] arr=new int[]{98,99,100,123};
//          数组获取最大值
        int max=arr[0];
        for (int x=1;x<arr.length;x++){
            if(arr[x]>max){
                max=arr[x];
            }
        }
        System.out.println("max:"+max);

    }

}

posted @ 2022-08-02 00:09  NiceTwocu  阅读(768)  评论(0编辑  收藏  举报