Zookal
Zookal

We’d love to hear any feedback or comment from you!

© 2011-2021 Zookal Pty Ltd

View question and answer

From our collection of questions and answers
Other · Other
Question details

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class ListTest
{
public static void main(String[] args)
{
String[] costumes =
{"Dracula", "Spiderman", "Werewolf", "Wonderwoman", "Nurse", "R2D2", "Pilot"};
  
// #1 Create a list1 using the asList method
List<String> list1 = Arrays.asList("Dracula", "Spiderman", "Werewolf", "Wonderwoman", "Nurse", "R2D2", "Pilot");

String[] scaryCostumes =
{"Dracula", "Zombie", "Werewolf", "Axe Murderer", "Blob"};
// #2 Create a list using the asList method

// #3 concatenate lists into list1 using addAll
// #4 release resources of list2

printList(list1); // print list1 elements


printList(list1); // print list1 elements
  
System.out.printf("%nDeleting elements 4 to 6...");
removeItems(list1, 4, 7); // remove items 4-6 from list
printList(list1); // print list1 elements
printReversedList(list1); // print list in reverse order
}

// output List contents
private static void printList(List<String> list)
{
System.out.printf("%nlist:%n");

for (String costume : list)
System.out.printf("%s ", costume);

System.out.println();
}


// obtain sublist and use clear method to delete sublist items
private static void removeItems(List<String> list,
int start, int end)
{
//#5 use sublist and clear to remove items
} // end method removeItems

// print reversed list
private static void printReversedList(List<String> list)
{
ListIterator<String> iterator = list.listIterator(list.size());
System.out.printf("%nReversed List:%n");
//#6 print list in reverse order

}
} // end class ListTest

Answer
Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.

Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.