Here is the Java code.
- public class Array {
- public static void main(String[] args) {
- int num[] = new int[] {
- 59, 53, 73, 85, 25, 97, 23, 87, 03, 79
- };
- int small = num[0];
- int big = num[0];
- for (int i = 1; i < num.length; i++) {
- if (num[i] > big) big = num[i];
- else if (num[i] < small) small = num[i];
- }
- System.out.println("Largest Number in given array is : " + big);
- System.out.println("Smallest Number in given array is : " + small);
- }
- }
Thank you, keep learning and sharing.