I have an object called a Contact that has a bunch of attributes. I also have an array of Contacts called Contact_List, and I have to write a method for the Contact_List that will add a Contact object to it. That part is easy, but it has to ensure that all of the Contacts within it are in order based on their last names. I already have an accessor called getLastName that returns the String of their last name, but how do I make the method add the contact and order them? Please Help, this is due in an hour and a half!
public void add(Contact frnd)
{
if(numContacts == MAX_CONTACTS) // If the List is already full
{
System.out.println("The Contact List is already at Maximum Capicity");
}
else
{
numContacts += 1; // There is one more Contact
Contact_List[numContacts - 1] = frnd; // Assigns the Last Open Spot the new Contact
}
}