Performance of variable argument methods in Java

前端 未结 6 1151
小鲜肉
小鲜肉 2020-12-19 20:42

I have this question about the performance of a method in Java with a variable number of parameters.

Say I have the following 2 alternatives:

public          


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-19 21:11

    It will be the same as if you declared

     isIn(int i, int[] values) {
    

    However there will be some some small overhead in packaging the variables up when calling your method

提交回复
热议问题