In the Following example LargestandSmallestnumber shows how to Find Largest and Smallest Number in an Array Using Java Example
Here is the java Example for the program LargestandSmallestnumber :
public class LargestandSmallestnumber { public static void main(String[] args) { //array of 15 numbers int no[] = new int[]{42,48,33,44,32,75,83,28,53,13,88,99,33,44,55}; //assign the value to first element of an array to largest and smallest int small = no[0]; int large = no[0]; for(int i=1; i< no.length; i++) { if(no[i] > large) large = no[i]; else if (no[i] < small) small = no[i]; } System.out.println("The Largest number is : " + large); System.out.println("The Smallest number is : " + small); } }