Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. write a class called TelDirectory that implements the Comparable interface. T

ID: 3671780 • Letter: 1

Question

1. write a class called TelDirectory that implements the Comparable interface. The class should contain two fields name (String) and phone number (String). Write the necessary constructors, accessors, mutators and other methods.

2. write a client class that creates an ArrayList of 10 TelDirectory objects called list1.

print the list

call collections.sort(list1), to sort the elements according to the name. if the names are the same then sort the list using the phone number.

print the sorted list.

Explanation / Answer

Also, two lists with different type parameter can be equals:

You also mentioned that the list must contain elements with the same type. Here's yet another example where the elements don't have the same type, and yet they're equals:

So unless you clearly define what equality means to you, the question can have very different answers. For most practical purposes, though, List.equals should suffice.