问题描述
如果我错了,请纠正我.是Boxing + Varargs优先于Boxing + Widening吗?
Please correct me if I'm wrong. Is Boxing+Varargs is preferred over Boxing+Widening?
我在网站中找到相反.
推荐答案
在 JLS#15.2.2 :
第二阶段(第15.12.2.3节)在允许装箱和拆箱的同时执行重载解析,但仍排除使用可变arity方法调用.如果在此阶段未找到适用的方法,则处理将继续进行到第三阶段.
The second phase (§15.12.2.3) performs overload resolution while allowing boxing and unboxing, but still precludes the use of variable arity method invocation. If no applicable method is found during this phase then processing continues to the third phase.
第三阶段(第15.12.2.4节)允许将重载与可变arity方法,装箱和拆箱相结合.
The third phase (§15.12.2.4) allows overloading to be combined with variable arity methods, boxing, and unboxing.
因此,总而言之:扩展>装箱和拆箱>可变参数
So in summary: widening > boxing&unboxing > varargs
这篇关于装箱+瓦尔格人优先于装箱+野兽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!