class Value {
public void method1(List<Integer> intList) {
}
public void method1(List<Double> doubleList) {
}
}
Not able to use function overloading in the above two methods.
This looks like both the methods are taking List as a parameter.
Is there a way to differentiate the parameters on the data type of Lists?
This is the error message:
Erasure of method method1(List<Integer>) is the same as another method in type Value
Is there any other way through which I can use overloading here?
You cannot declare more than one method with the same name and the same number and type of arguments, because the compiler cannot tell them apart. See oracle docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With