Strange behaviour with Object.intValue()

前端 未结 2 860
遇见更好的自我
遇见更好的自我 2021-01-16 16:56

I am struggling with a problem, which I can\'t understand why it doesn\'t work. How do I pass a variable through the double obj and convert to int

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-16 17:20

    The double is a primitive type, while the Double is a regular Java class. You cannot call a method on a primitive type. The intValue() method is however available on the Double, as shown in the javadoc

    Some more reading on those primitive types can be found here

提交回复
热议问题