I have a method findByProperties(Parameter… p); so it can take any number of parameters. But what I am confused is if I had to call this method and I do not know the number of parameters how do I do that
suppose I have a list with parameters, and the size of the list changes each time you call the method, the how would I add the parameters from the list to the method call?
for(ArrayList<Parameter> p : list){
findByProperties(p); //not sure what to do here
}
EDIT:
this was the solution:
Parameter[] paramArray = new ArrayList<Parameter>().toArray(new Parameter[]{});
findByProperties(paramArray);
You can do something like this:
It’s the same as something like:
Because Java internally transforms a varargs-list into an array, so you can pass an array, too.