Why does the Double.valueof javadoc say it caches values, when it doesn't?

前端 未结 6 1598
小鲜肉
小鲜肉 2020-12-15 02:30

In OpenJDK, for the method:

public static Double valueOf(double d)

The javadoc says:

Returns a Double instance repre

6条回答
  •  無奈伤痛
    2020-12-15 03:07

    These valueOf() methods exist in every numeric type for the purpose to support caching. In fact, for Double it does not use any cache but for Integer and Long.

提交回复
热议问题