Question
Write a class ContactList meeting the following specifications: The ContactList class should import the java.util.ArrayList class and the java.util.Collections class. The ContactList class should have
Write a class ContactList meeting the following specifications:
The ContactList class should import the java.util.ArrayList class and the java.util.Collections class.
The ContactList class should have one field contacts which is an arraylist of type Contact.
The ContactList should have one constructor with no parameters. The constructor should initialize the contacts arraylist.
The ContactList class should have a method with header: public void addContact(String lastName, String firstName, String number)
The addContact method should create a new Contact object and add the new Contact object to the arraylist contacts.
The ContactList class should have a toString which sorts the arraylist contacts using the Collections.sort() method and then returns a string that contains all of the information for every contact in the contacts arraylist.
The ContactList class should have a method with header: public String searchContacts(String searchString)
The searchContacts method should return a string that contains all of the information for every contact in the contacts arraylist that contains the value of the searchString parameter.
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