Java Trap – Autoboxing and Unboxing
The below program is a typical Java trap, and also a popular Java interview question. It has no compiler error or warning but running very slow. Can you spot the problem? JavaSum.java package com.mkyong; import java.time.Duration; import java.time.Instant; public class JavaSum { public static void main(String[] args) { Instant start = Instant.now(); Long total = …