Sort numbers random in array

import java.util.*;

class FillAndSort {
   public static void main( String[ ] args ) {
      if ( args.length != 1 ) {
        System.err.println( "java FillAndSort <number of doubles>" );
        return; //*** exits main and, therefore, the program stops
      }
      int n = Integer.parseInt( args[ 0 ] ); //** convert String to int
      double[ ] nums = new double[ n ];
      Random r = new Random();               //** construct a Random
      int i = 0;
      while ( i < n ) {                      //** fill with doubles
         nums[ i ] = r.nextDouble();         //** next random double
         i = i + 1;
      }
      print( nums );                         //** print array
      Arrays.sort( nums );                   //** sort array
      print( nums );                         //** print again
   }
   static void print( double[ ] a ) {
      System.out.println();
      for ( int i = 0; i < a.length; i++ )
         System.out.println( a[ i ] );
   }   
}

Was there a question, or did you just want to share this code with us all?

No,i have the above code.
How to compile the above code to output the results with sort?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.