Overloading by return type

No there isn’t. You can’t overload methods based on return type. Overload resolution takes into account the function signature. A function signature is made up of: function name cv-qualifiers parameter types And here’s the quote: 1.3.11 signature the information about a function that participates in overload resolution (13.3): its parameter-type-list (8.3.5) and, if the function … Read more

Properly removing an Integer from a List

Java always calls the method that best suits your argument. Auto boxing and implicit upcasting is only performed if there’s no method which can be called without casting / auto boxing. The List interface specifies two remove methods (please note the naming of the arguments): remove(Object o) remove(int index) That means that list.remove(1) removes the … Read more

How to achieve function overloading in C?

Yes! In the time since this question was asked, standard C (no extensions) has effectively gained support for function overloading (not operators), thanks to the addition of the _Generic keyword in C11. (supported in GCC since version 4.9) (Overloading isn’t truly “built-in” in the fashion shown in the question, but it’s dead easy to implement … Read more

Method Overloading for null argument

Java will always try to use the most specific applicable version of a method that’s available (see JLS §15.12.2). Object, char[] and Integer can all take null as a valid value. Therefore all 3 version are applicable, so Java will have to find the most specific one. Since Object is the super-type of char[], the … Read more

Does Java support default parameter values?

No, the structure you found is how Java handles it (that is, with overloading instead of default parameters). For constructors, See Effective Java: Programming Language Guide’s Item 1 tip (Consider static factory methods instead of constructors) if the overloading is getting complicated. For other methods, renaming some cases or using a parameter object can help. … Read more