/**
 * This class demonstrates fixing the autoboxing inefficiency.
 * 
 * @author Sara Sprenkle
 */
public class AutoboxFixed {

	/**
	 * Called when user runs java Autobox
	 */
	public static void main(String[] args) {

		// Find the inefficiency in the code below.

		long startTime = System.currentTimeMillis();
		long sum = 0L;
		for (long i = 0; i < Integer.MAX_VALUE; i++) {
			sum += i;
		}
		System.out.println(sum);
		long finishTime = System.currentTimeMillis();
		double seconds = (finishTime - startTime)/1000.0;
		System.out.println("Elapsed time: " + seconds + " s");
	}
}
