What is the difference between autoboxing and coercion? [closed]

拟墨画扇 提交于 2019-12-11 16:25:12

问题


I program in Java, C and Python.

The rule for automatic coercions among arithmetic types have been augmented to handle the richer set of types

Source: "The C Programming Language"

But what does "coercion" mean? The answers say it's like type conversion and implicit casts and implicit type conversions and called autoboxing where I read it. So what is the difference between automboxing and coercion?

Thanks


回答1:


Coercion is another name for an implicit type cast, i.e. one mandated by the language rules, and not explicitly added by the programmer.




回答2:


Coercion refers to "type coercion". In other words, you add a variable of type Integer to a Float, the Integer will be coerced to Float, and the numbers added together.




回答3:


Coercion is the process of changing one data type into another. http://en.wikipedia.org/wiki/Type_conversion



来源:https://stackoverflow.com/questions/11086114/what-is-the-difference-between-autoboxing-and-coercion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!