import java.util.*; class FinnSumError{ public static void main(String[] args){ if (args.length != 1) { System.out.println ("use: >java FinnSumFeil n" ); }else { int len = new Integer(args[0]).intValue(); FinnSumError fs =new FinnSumError(); for (int k = 0; k < 20; k++){ int [] arr = new int[len]; for (int i = 0; i < arr.length; i++){ arr[i] = i; } long start = System.nanoTime(); long sum = fs.summer(arr); long timeTaken = System.nanoTime() - start ; // System.out.printf(", SUM: %12d", sum ); System.out.printf(" %2d) sum of:%9d numbers on :%10d nanosec%n", (k+1), len,timeTaken); }} } // end main long summer(int [] arr){ long sum = 0; for(int i = 0; i < arr.length; i++) sum += arr[i]; return sum; } } // end summer