I am trying to write a Set<E> interface in Java, that will be implemented by another class mySet<E> utilising an arrayList<E> to store the elements.
I intend to include regular set functions: add(), remove(), union() intersection() etc.
What should the type be for my add() and remove() functions? I have tried using add(Object E) and add(<E>) but am running into errors.
add(E objToAdd);
remove(E objToRemove);
Reference - Generics In Java
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