1

I have few overloaded method, which I can replace with vararg, but these are getting called numerous times.

I just wanted to know its impact. I assume jvm creates an array from the parameters at runtime, so theoretically there must be some impact, not sure practically will it impact or not!

GhostCat
  • 133,361
  • 24
  • 165
  • 234
krmanish007
  • 6,090
  • 12
  • 52
  • 92

1 Answers1

1

The one and only answer that makes sense here: go and measure yourself. Yes, you are correct - varargs are syntactic sugar - and the compiler creates arrays under the hood. So, yes - there is a certain performance impact.

But if that penalty really matters to you depends solely on your requirements and your context.

I think (opinion) here: when this really impacts the perceived performance of your application - then you probably have other problems already.

GhostCat
  • 133,361
  • 24
  • 165
  • 234