Code:
public DoublyLinkedList<T> tail( int n )
{
if ( size() > n )
{
DoublyLinkedList newList = new DoublyLinkedList<>();
Element<T> current = first;
int t = size() - n;
for ( int i = 0; i < t; i++ )
{
current = current.getSucc();
}
newList.first = current;
for(int i = 1; i<size; i++)
{
current = current.getSucc();
}
newList.last = current;
newList.size = n;
size = size- n;
return newList;
}
else
{
throw new RuntimeException();
}
Wo liegt der Fehler?
Zuletzt bearbeitet: