1.
public class GetMax { public static void main(String[] args){ int[] arr = {-100,-20,20,10,25,80,99,35,105,888}; System.out.println(getMax(arr)); } private static int getMax(int[] arr) { int max = arr[0]; for (int i = 1; i < arr.length; i++) { if(arr[i] > max){ max = arr[i]; } } return max; } }
时间: 2024-12-29 23:23:33