package useMethod;
public class returnMax {public static void main(String [] ages){
int []data = {12,136,98,111};
int []data2 = {15,186,28,365};
method a=new method();
int Max1 = a.getMax(data);
int Max2 = a.getMax(data2);
int max = Max1;
if(Max2>max){
max = Max2;
}
System.out.println("最大值为:"+max);
}
}
//方法
package useMethod;
public class method {
public int getMax(int []data){
int max = 0;
for(int i = 0; i<data.length;i++){
if(max<data[i]){
max = data[i];
}
}
return max;
}
}