I was wondering if you can suggest something here.
I would like to have 2 methods:
doSomething(List<Data>) and
doSomething(List<Double>)
Since type of parameter is the same, Java is complaining
Is there a way to somehow make this overloading happen?
Sadly, no. Because Java implements generics via erasure those two methods would both compile down to:
doSomething(List)
Since you cannot have two methods with the same signature this will not compile.
The best you can do is:
doSomethingData(List<Data>)
doSomethingDouble(List<Double>)
or something equally nasty.
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