feat: The set method for setting the value of a node by index.

This commit is contained in:
Гаджикурбанов Темирлан
2026-08-24 00:48:14 +03:00
parent ef1c54f10e
commit a7861dd58a
@@ -59,6 +59,17 @@ public class MyLinkedList<T> implements MyList<T>
}
}
}
public T set(int index, T value) {
if (index < 0 || index >= size) {
throw new IllegalArgumentException();
}
Node temp = head;
for (int i = 0; i < index; i++) {
temp = temp.getNext();
}
public String toString() {
Object[] res = new Object[size];
int index = 0;