// Timing program execution class Elapsed { public static void main( String args[] ) { long start; long end; System.out.println( "Timing a for loop from 0 to 100,000" ); // time a loop for 0 to 100,000 start = System.currentTimeMillis(); //get starting time for ( int i = 0; i < 100000; i++ ); end = System.currentTimeMillis(); // get ending time System.out.println( "Elapsed time: " + (end-start) ); } }