拳击和拓宽 [英] Boxing and Widening

查看:212
本文介绍了拳击和拓宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两者之间有什么区别。我知道Boxing正在将原始值转换为引用。什么在扩大。还应该完成第一次拳击应该完成或扩大应该做什么?

What is the difference between these two. I know Boxing is converting primitive values to reference. What is widening. Also what should be the sequence first boxing should be done or widening should be done?

推荐答案

拓宽正在改变另一个变量更宽的类型。

可以使用原始类型或引用类型进行扩展。

Widening is transforming a variable in another with a wider type.
Widening can be done with primitive or reference types.

例如:

字符串 - > 对象

int - > long

String -> Object
int -> long

正如JLS所述:


拳击转换(§5.1.7) [可选]后面加宽参考转换

a boxing conversion (§5.1.7) [is] optionally followed by a widening reference conversion






资源:




  • JLS - 扩展原始转换

  • JLS - 扩展参考转换


  • Resources :

    • JLS - Widening Primitive Conversion
    • JLS - Widening Reference Conversions
    • 这篇关于拳击和拓宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆