In: Computer Science
Using import java.util.Random, create a simple java code that populates an array with 10 random numbers and then outputs the largest number.
JAVA PROGRAM
import java.util.*;
import java.util.Random;
public class Main
{
   public static void main(String[] args) {
       Random random = new Random();
       //declaration of array
       int arr[] = new int[10];
       int lar = 0,i;
       //runs the loop
       for(i=0;i<10;i++)
       {
       //generates the random number &
stores it in Array
       arr[i] = random.nextInt();
       }
       lar = arr[0];
       //runs the loop to find the largest
number in Array
       for(i=0;i<10;i++)
       {
       //checks the conditon
       if(lar<arr[i])
       {
       lar = arr[i];
       }
   }
   //prints the largest number
   System.out.println("Largest number: "+lar);
   }
}
