Method Overloading and Ambiguity in Varargs in Java - GeeksforGeeks
Method Overloading in Varargs
Overloading allows different methods to have same name, but different signatures where signature can differ by number of input parameters or type of input parameters or both. We can overload a method that takes a variable-length argument by following ways:
- Case 1 – Methods with only Varargs parameters: In this case, Java uses the type difference to determine which overloaded method to call. If one method signature is strictly more specific than the other, then Java chooses it without an error.
Read full article from Method Overloading and Ambiguity in Varargs in Java - GeeksforGeeks
No comments:
Post a Comment