Created
October 29, 2017 15:05
-
-
Save PocasPedro/874165259080048e6500adbe11e76e15 to your computer and use it in GitHub Desktop.
Java Fundamentals for Kids - Exercise 19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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