public class RandomArray2 { public static void main (String[] argv) { double p = estimateSortedProb (5, 100000); System.out.println ("Probability an array of length 5 is sorted: " + p); } static double estimateSortedProb (int arraySize, int numTrials) { // Count the number of sorted arrays generated. int numSorted = 0; // Repeat for given number of experiments. for (int n=0; n