public class methods {
public static void main(String[] args) {
int[] array = {2, 3, 4, -2, 10, 32};
int getMax = max(array);
System.out.println(getMax);
printArray(array);
}
// This is returd method while you call array into the main class
public static int max(int[] array) {
int max = array[0];
for(int i =0; i< array.length; i++) {
if(array[i]> max) {
max = array[i];
}
}
return max;
}
//this is method that print array while you call into main class
public static void printArray(int [] array) {
for(int i=0; i<array.length; i++) {
System.out.print(array [i] + " ");
}
}
}
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