Is there a way to override a Java method that the only thing that changes is an ArrayList?
For example:
public void quickSortMethod(ArrayList<Integer> comparison, int start, int end)
{}
public void quickSortMethod(ArrayList<Double> comparison, int start, int end)
{}
This currently gives me the following error:
Method quickSortMethod(ArrayList<Integer>, int, int) has the same erasure quickSortMethod(ArrayList<E>, int, int) as another method in type QuickSort
Btw I'm using other objects I created as parameters in the ArrayLists
ArrayList<MyObject>...
In this case you could try making the method itself generic and using that type as the ArrayList type...
public <T> void quickSortMethod(ArrayList<T> comparison, int start, int end)
Unfortunately, no. Because of type erasure after compilation there's no difference between the two.
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