在java
double number = (double) integer;This would give you access to all of the methods and properties of the MyClass class。
何时使用casting
铸造如果无法正确完成,则可能是危险的。如果将对象施放为不正确的类型,则将获得ClassCastException。重要的是要注意铸造所涉及的风险,并且只有在确定对象是正确类型的情况下才能做到的。
免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3