ircle ONLY 10 items) lease enter your coding solution to the follow case based q
ID: 3601147 • Letter: I
Question
ircle ONLY 10 items) lease enter your coding solution to the follow case based questions in the noted area for each uestion. int: I should be able to copy and paste this code into eclipse and it should run properly. There is artial credit for these questions so make sure you try your best! Do not leave these questions blank. rogramming Question 1: 15 points reate a program that adds a value to a linked list, displays the contents of the list, removes that value d then displays the contents of the linked list on the user's screen. port java.util.LinkedList; blic class PQ1 public static void main(String[] args) //KENTER YOUR CODE HERE>Explanation / Answer
Here is the code :
import java.util.LinkedList;
public class PQ1 {
public static void main(String[] args) {
//Create linked list
LinkedList<String> list = new LinkedList<String>();
//add value
list.add("Value1");
//Display contents of list after adding value
System.out.println("Displaying content of the list after adding value : ");
for(int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
//Deleting value
System.out.println("Deleting Value 1 from the list");
list.remove("Value1");
//Display contents of list after deleting value
System.out.println("Displaying content of the list after deleting value : ");
for(int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
}
}
Output :
Displaying content of the list after adding value :
Value1
Deleting Value 1 from the list
Displaying content of the list after deleting value :
**If you have any query , please feel free to comment with details.
**Happy learning :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.