package com.loveCoding.j20250517_java_array;

/**
 * @author WanJl
 * @version 1.0
 * @title Demo05
 * @description 数组获取最大值:从数组的所有元素中找到最大值
 * @create 2025/5/17
 */
public class Demo05 {
    public static void main(String[] args) {
        int[] arr={15,6,4,163,49,8,1,68,49};
        int max=0;
        for (int i = 0; i < arr.length; i++) {  //遍历数组
            if(arr[i]>max){ //判断如果一个数组元素大于最大值
                max=arr[i];//就把这个元素赋值给max
            }
        }
        System.out.println("数组中最大的元素是:"+max);
    }
}