Should autoboxing be avoided in Java?

前端 未结 5 1555
谎友^
谎友^ 2021-01-17 12:51

There are instances where a method expects a primitive type double and you pass a Double object as a parameter.

Since the compiler unboxes

5条回答
  •  终归单人心
    2021-01-17 13:37

    You don't have to avoid autoboxing if talking about performance, JVM should handle that. The only thing you should consider is a readability of your code.

提交回复
热议问题