//找出数组中最小值的下标位置,用方法封装classHomeWork6{publicstaticvoid main (String[]args){int[] arr ={12,56,565,13,79,78,651,87,10,25,};int min =minnum(arr);
System.out.println("最小值下标 :"+min);}/**
*循环数组找出最小值的下标
*
*@param int min保存最小值下标
*
*@return min 传回保存下标的值
*/publicstaticint minnum (int[] arr){int min =0;for(int i =1; i < arr.length; i++){if(arr[min]> arr[i]){
min = i;}}return min;}}
// 找出数组中最大值的下标位置,用方法封装classHomeWork5{publicstaticvoid main (String[]args){int[] arr ={12,56,565,13,79,78,651,87,10,25,};int max =intprice(arr);
System.out.println("最大值的下标 :"+ max);}/**
*循环数组找出最大值的下标
*
*@param int max 储存下标的值
*/publicstaticintintprice(int[] arr){int max =0;for(int i =1; i < arr.length; i++){if(arr[max]< arr[i]){
max = i;}}return max;}}