I am new to Java and writing a method for a generic Linked List that accepts another Linked List as a parameter. As I understand, this new Linked List should be of the same type as the Linked List calling the method.
So, instead of
public void insertList(MyLinkedList<AnyType> otherList, int idx) {
I should be specifying the type of otherList to match the list that calls insertList()?
list.insertList(MyLinkedList<???>, 0);
How would I do this if I don't know the type of list, since it's generic, but know that otherList needs to be the same type? I hope that makes sense. As I mentioned, I am new to Java, so if I am misunderstanding generics, please correct me. Thank you.
List<Integer>to aList<String>, are you?I should be specifying the type of otherList to match the list that calls insertList()?means.