Language syntax

Java method overloading

Selection is at compile time; applicable fixed-arity candidates are considered before variable-arity invocation.

Formal Syntax & Structure

java syntaxjava
choose(long); choose(int...);

Working Example

Example Snippetjava
public class Main {    static String choose(long value) { return "long"; }    static String choose(int... values) { return "varargs"; }    public static void main(String[] args) {        System.out.println(choose(5));        System.out.println(choose(5, 6));    }}
Java Reference