Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Declare an ArrayList of Strings. Add 5 names to the collection. Bob Susan Output the Strings onto the console using the enhanced for loop 3.
Declare an ArrayList of Strings. Add 5 names to the collection. "Bob" "Susan Output the Strings onto the console using the enhanced for loop 3. import java util. 4. public class Assignment8 {5. 6. public static void main (String[] args) {7.//TODO Auto-generated method stub 8. Array List new Array list(); 9. Add(Bob) 10. a Susan 11. a add(Jeremy) 12. a. add Emil 13. Laura 14 for (object obj: a) The enhanced For Loop f 15. 16. 17.} Sort the list using the method Collections sort, Output the sorted List. Shuffle the list, and output the shuffled list. Note that Collections (with an s is a class, while Collection is an interface. The Collections class has many useful static methods for processing interfaces, including the sort method Search for the name "Susan" in the list. What location was it found? Search for a names that is not in the list. What location is reported? Describe why an equals method and a compare To method are required to achieve searching and sorting of the elements of a list. Convert the list above to an array using to Array Output the elements of the array. Convert the array back into a list using asList. Output the elements of the list. Describe the differences between a HashSet. TreeSet, and a LinkedHashSet. When might you choose each one of these? Describe the differences between a HashMap, TreeMap, and LinkedHashMap Describe the situation when might you use each of these
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started