Code Below:
import java.util.*;
class largestsmallest
{
public static void main()
{
Scanner s=new Scanner(System.in);
int i,small,large;
int arr[]=new int[10];
System.out.println("ENTER 10 NOS.");
for (i=0;i< 10;i++)
arr[i]=s.nextInt();
small=arr[0];
large=arr[0];
for (i=0;i< 10;i++)
{
if (arr[i]< small)
small=arr[i];
if (arr[i]>large)
large=arr[i];
}
System.out.println("Smallest="+small);
System.out.println("Largest="+large);
}
}