/**
 * This class demonstrates inefficiencies with unnecessary autoboxing.
 * Note that changing the loop's counter variable to an int does *not*
 * help with respect to improving runtime because the autoboxing is
 * still occuring. 
 * 
 * @author Sara Sprenkle
 */
public class AutoboxInt {

	public static void main(String[] args) {

		// Find the inefficiency in the code below.

		long startTime = System.currentTimeMillis();
		Long sum = 0L;
		for (int 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");
	}
}
