Java Optimizations

前端 未结 5 1766
忘了有多久
忘了有多久 2021-01-24 04:38

I am wondering if there is any performance differences between

  1. String s = someObject.toString(); System.out.println(s);

    and

  2. System.out.pr

5条回答
  •  醉话见心
    2021-01-24 05:16

    The generated bytecode is not a good measure of the the performance of an given piece of code, since this bytecode will get analysed, optimised and ( in case of the server compiler ) re-analysed and re-optimised if it is deemed to be a performance bottleneck.

    When in doubt, use a profiler.

提交回复
热议问题