Advertisement
Guest User

Untitled

a guest
Feb 9th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. package jjj;
  2.  
  3. public class jjj {
  4.   public static void main( String[] args ) {
  5.     int[] arr = new int[10000000];
  6.    
  7.     for (int i = 0; i < 10000000; i++) {
  8.       arr[i] = i;
  9.     }
  10.    
  11.     long t0 = System.currentTimeMillis();
  12.     long sum = 0;
  13.    
  14.     for (int i = 0; i < 10000000; i++) {
  15.       sum += arr[i];
  16.     }
  17.    
  18.     long t1 = System.currentTimeMillis();
  19.    
  20.     System.out.println("The call took "+(t1 - t0)+"ms to run. Sum is "+sum);
  21.   }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement