I would something like the following recursive method:
private Node getElementRec(Node currentNode, String ... names) {
if (null == names || names.length == 0)
return currentNode;
else {
Node child = currentNode.getChildWithName(names[0]);
return getElementRec(child, namesAux.subList(1, names[1,]));
}
}
Since variable length Java parameters (here names) are arrays, I cannot make something like names.sublist(1, names.size()) Although it would be rather inefficient, I’ve tried to convert the array to a list and then pass it to the method, but it doesn’t accept a list
So the question is: is it possible in Java to do recursion over a variable length parameter (Type ... parameter)? Something like I showed is possible?
Thanks
Pass the index