0
import java.util.ArrayList;
import java.util.Collections;
public class PersonMaker
{

    public static void main(String[] args) 
    {
        ArrayList<Person> personAL = new ArrayList<Person>();

        ArrayList<Address> addressList = new ArrayList<Address>();
        Address c0 = new Address("2100 Pleasant Hill road", "duluth", "GA", "30096");
        Address c1 = new Address("3392 fairway oaks", "lawrenceville", "Georgia", "30044");
        Address c2 = new Address("4493 Pleasant hill road", "Duluth", "Georgia", "30096");


        ArrayList<Phone> phoneAL = new ArrayList<Phone>();
        Phone d0 = new Phone(404, "9932116");
        Phone d1 = new Phone(678, "4432423");
        Phone d2 = new Phone(470, "4432423");

        Collections.sort(addressList);
        System.out.println("sorted");

        }
    }

my question is Construct 3 people with different addresses and phone numbers (do not generate the data)
Add them to an array list of Person
Sort each of the people’s addresses and phone numbers (Collections.sort for the address and
phone array lists)

Edited by Dani: Imports repeated twice

3
Contributors
3
Replies
17
Views
2 Years
Discussion Span
Last Post by stultuske
1

shouldn't address and phone number be fields of the person class?

Person
    Name
    Age
    Address
    PhoneNumber



Then if you want to have your objects in the arraylist
person1 = new Person(name,age,address,phonenumber)
person2 = new Person(name,age,address,phonenumber)
person3 = new Person(name,age,address,phonenumber)
arraylist.add(..)...

Edited by Slavi

Votes + Comments
That's right.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.