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.
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!
Learn more about our help with Assignments:
JavaJSPJSF