public class LargestSmallest { public static void main(String[] args) { int a[] = new int[] { 23, 34, 13, 64, 72, 90, 10, 15, 9, 27 };

int min = a[0]; // assume first elements as smallest number int max = a[0]; // assume first elements as largest number

for (int i = 1; i < a.length; i++) // iterate for loop from arrays 1st index (second element) { if (a[i] > max) { max = a[i]; } if (a[i] < min) { min = a[i]; } }

System.out.println("Largest Number in a given array is : " + max); System.out.println("Smallest Number in a given array is : " + min); }

}

Output:

Largest Number in a given array is : 90 Smallest Number in a given array is : 9

Yamini Chinni
Good it is very easy to understand yaminkumar
Nice there are very used on . Nishant Kumar
NNNNNNNNNNNNNNNice there are very used onnnnnnnnnnnnnn bob
why does the code have so much spaces???? yuvaraj
to understand easily