Please don\'t use handwriting in answers, because I cannot understand it. The an
ID: 3826097 • Letter: P
Question
Please don't use handwriting in answers, because I cannot understand it.
The answer related with java
20 Marks Question Five Using a LinkedList and Listlterator classes from the java library packages. Write a program that contains a list of courses' codes. Your program should do the following functions in order. 1. Add the following courses in the list: "CS141 "CS140" and "IT409" 2. Remove the course "CS141 from the list and return it in "removed" variable 3. Add the course T448" after the course "CS140" 4. Prints all the courses in the list using List terator object.Explanation / Answer
LinkedListTest.java
import java.util.LinkedList;
import java.util.ListIterator;
public class LinkedListTest {
public static void main(String[] args) {
LinkedList<String> list = new LinkedList<String>();
list.add("CS141");
list.add("CS140");
list.add("CS409");
boolean removed = list.remove("CS141");
list.add(1,"CS448");
ListIterator<String> itr = list.listIterator();
while(itr.hasNext()){
System.out.println(itr.next());
}
}
}
Output:
CS140
CS448
CS409