I have a method. I transfer to it the name of the new data object and its future number num . I have a single linked list.
My idea is this: to find the predecessor by number, extract the link to the child from it, specify the link to the new object instead of it and place the extracted link in it. The question is how to extract the link and pass it on? And in general, can this be done?
public static void addTo(String data, int num) { int count = 0; Node1 elem = new Node1(); elem.data = data; Node1 temp=head; while (count < num) { if (num - count == 1){ //temp=temp.next; //count ++; } //else } }
add(int index, T element);- Oleg