美文网首页
Java widening taking priority ov

Java widening taking priority ov

作者: 石头2017 | 来源:发表于2017-08-18 08:49 被阅读0次

Java 和 Groovy区别

Because Groovy uses Objects for everything, it autowraps references to primitives. Because of this, it does not follow Java’s behavior of widening taking priority over boxing. Here’s an example using int


int i

m(i)

void m(long l) {

println "in m(long)"

}

void m(Integer i) {

println "in m(Integer)"

}

This is the method that Java would call, since widening has precedence over unboxing.

This is the method Groovy actually calls, since all primitive references use their wrapper class.       

相关文章

网友评论

      本文标题:Java widening taking priority ov

      本文链接:https://www.haomeiwen.com/subject/amporxtx.html