Is the Java compiler smart enough to optimize loop below, by extracting the
Double average = new Double( totalTime / callCount );
out of t
Not really. The compiler just writes out byte-code. If anything optimized the code, it'd be the Java Virtual machine and that probably depends on the platform, implementation and execution conditions...