+ 3

why this program always different time for (for loop)

long start, end; System.out.println("Timing a for loop from 0 to 100,000,000"); // time a for loop from 0 to 100,000,000 start = System.currentTimeMillis(); for(long i=0; i < 100000000L; i++) ; end = System.currentTimeMillis(); System.out.println("Elapsed time: " + (end-start));

3rd Sep 2017, 6:32 AM
Deependra Singh Rathore
Deependra Singh Rathore - avatar
1 Réponse
+ 7
Because the speed of the compiler isn't always the same
3rd Sep 2017, 6:44 AM
Dapper Mink
Dapper Mink - avatar