Skip to content

Instantly share code, notes, and snippets.

@PocasPedro
Created October 29, 2017 15:05
Show Gist options
  • Save PocasPedro/874165259080048e6500adbe11e76e15 to your computer and use it in GitHub Desktop.
Save PocasPedro/874165259080048e6500adbe11e76e15 to your computer and use it in GitHub Desktop.
Java Fundamentals for Kids - Exercise 19
public class ArrayMinAndMax {
public static void main(String[] args) {
//Define & Initialization
int numbers[] = new int[] {1,333,17,6,47,8,14,43};
int min = numbers[0];
int max = numbers[0];
for(int i = 0 ; i < numbers.length ; i ++){
if ( numbers[i] < min )
min = numbers[i];
if ( numbers[i] > max )
max = numbers[i];
}
System.out.println("The minimum value of the array is " + min);
System.out.println("The maximum value of the array is " + max);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment