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
The compiler does next to no optimisation. The JVM can optimise code but the two methods won't perform anything like each other. If you have lines of code like isIn(i, 1,2,3,4,5,6,7,8,9 /* plus 40 more */)
you have more than performance issues to worry about IMHO. I would worry about readability first.
If you are worried about performance pass the arguments as a int[]
which is reused.
BTW The most efficient way to look up a large set of int values is to use a Set like TIntHashSet