bckr bckr - 1 year ago 72
Java Question

Function Overloading: Terminology for different types of overloaded functions?

For example, say I have these 3 overloaded functions:

/** Function #1 */
public static String add(List<String> operands)
return add(operands, 10);

/** Function #2 */
public static String add(List<String> operands, int base)

return Integer.toString(add(Integer.parseInt(operands.remove(0), base),operands, base), base);

/** Function #3 */
private static int add(int result, List<String> operands, int base)
if(operands.size() == 0)
return result;

result += Integer.parseInt(operands.remove(0), base);

return add(result, operands, base);

Would it be correct to call Function #2 in this case the "parent" overloaded function of Function #1 because Function #1 calls it and both are public?

Would it also be correct to call Function #3 the "recursive" function of these functions, or is there another term to describe the fact that it is called by the public functions as a hidden function that recursively calls itself?

I know those will not be the correct terms, but what I am trying to get at is whether there is set terminology for the different types of overloaded functions given their role.

Answer Source

I'd be reluctant to define any terms that the Java Language Specification doesn't.

Simply put your have 3 functions, 2 public and 1 private. They have the same name but different parameter types, so they are overloads.

Indeed a function that calls itself is a recursive function. The JLS does define that term since Java compilers must support functions that call themselves.

Don't refer to one of your functions as the "parent overload" - it's not particularly helpful, and your use of the term "abstraction" is idiosyncratic.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download