Program to find Smallest and Largest number in Java

Find Largest and Smallest Number in an Array means how to find largest and smallest number in an array.In this example we use 10 numbers in which we find the smallest and largest value.


public class FindLargeSmall


public static void main(String[] args)


                int numbs[] = new int[]{32,43,53,54,32,65,63,98,43,23}; //array of 10 numbers

                //assign first element of an array to largest and smallest

                int smallestno = numbs[0]; //assign first element of an array to smallest

                int largetstno = numbs[0];   //assign first element of an array to largest

                //for loop is used to find largest and smallest from start to end digit

              for(int i=1; i< numbs.length; i++)  


                if(numbs[i] > largetstno)   //condition check if true then

                largetstno = numbs[i]; //assign the value to largestst

               else if (numbs[i] < smallestno)  

                smallestno = numbs[i];


                System.out.println("Largest Number is : " + largetstno);

                System.out.println("Smallest Number is : " + smallestno);



smallestand largest number

    Explanation ….

In above program we use array for finding the smallest and largest number . We enter 10 number in an array and by using for loop we can find the result. Searching always start with zero. The index of the elements in an array always start with 0.



About Us

Rekha SetiaRekha Setia is a passionate blogger of Extra Computer Notes. if you have any ideas or any request me @