Functions -- Static Methods
class Max {
public static void main(String[] args){
int[] a = new int[]{5,6,1,2,7,9,0,10};
System.out.println(" max="+max(a));
}
static int max(int[] a){
int max = a[0];
for (int i=1; i<a.length; i++){
if (a[i]>max) max = a[i];
}
return max;
}
}
Previous slide
Next slide
Back to first slide
View graphic version