public static void main(String[] args) {
int[] array = {1,-2,3,0,5,6,7,8,100,10};
int myMax = max(array);
System.out.println("maxmimum number in the array is = " + myMax );
}
public static int max(int[] array) {
int max = 0;
for(int i =0; i< array.length; i++) {
if(array[i] > max) {
max = array[i];
}
}
return max;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter