Which method is called? (Integer… a) vs. (int a, int b)

后端 未结 5 549
无人共我
无人共我 2021-02-05 06:10

I just found out about a very interesting Java trick:

void method1(Integer... a){
}

So you can give this method as many integers as you want.

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-05 06:46

    A call will made to method1(int a, int b) . Just checked byte code for this - here Integer... a is actually an Integer[] a For a detailed conversion check these assignment conversion

提交回复
热议问题