Overloading with Short and int

前端 未结 2 1605
有刺的猬
有刺的猬 2020-12-11 02:30

Why this code will print int?

public static void main(String[] args) {
    short s = 5;
    A(s);
}
public static void A(int a){
    System.out.println(\"int         


        
2条回答
  •  感动是毒
    2020-12-11 02:50

    Because widening beats boxing

    Reason:

    Because widening was there long long before where boxing was introduced later on so not to break any code it does this.

提交回复
热议问题