Stephen R. Stephen R. - 3 years ago 180
Java Question

Deleting first n items of linked list

I am trying to create a method that will remove the first "n" items from the front of a LinkedList. Here's what a have so far...

public void removeFront(Node head, int n)
for(n != 0)
n = n -1
If(head != null)
Node temp =
head = temp

I think I have the right idea creating temp as the thing after head then making temp the new head but I don't know about the for loop. Any input on how to do this would be appreciated!

Answer Source

Just look up how to build a solid for loop.

for (int x = 0; x < 10; x++) { }

End your statements properly with ';'

And you've probably forgot that aswell, declare all your variables.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download