Answer to Question #4817 in Java | JSP | JSF for anthony hector

Question #4817
link list in java of length,n.a number,m is given and the program needs to on the mth node remove the node and continue doing so until the last node remains.
1
Expert's answer
2012-05-24T08:49:07-0400
import java.util.LinkedList;


public class Question4817 {

public static LinkedList list = new LinkedList();


public static void inputData(){
& list.add("Fisrt");
& list.add("1");
& list.add("Second");
& list.add("3");
& list.add("Four");
}

public static void removeData(){
& while(!list.isEmpty()){
& System.out.println(list.peek() + " removing");
& list.poll();
&
& }
}

public static void main(String[] args) {
& // TODO Auto-generated method stub
&
& inputData();
& removeData();
& System.out.println("Done!");

}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS