Phone book arraylist

The problem

Write a class named PhoneBookEntry that has fields for a person’s name and phone number. The class should have a constructor and appropriate accessor and mutator methods. Then write a program that creates at least five PhoneBookEntry objects and stores them in an ArrayList. Use a loop to display the contents of each object in the ArrayList.

Breaking it down

public class PhoneBookEntry {
    public PhoneBookEntry(String name, String phoneNumber) {
        super(); = name;
        this.phoneNumber = phoneNumber;
    private String name;
    private String phoneNumber;
    public String getName() {
        return name;
    public void setName(String name) { = name;
    public String getPhoneNumber() {
        return phoneNumber;
    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    public String toString() {
        return "PhoneBookEntry [name=" + name + ", phoneNumber="
                + phoneNumber + "]";

public static void main(String[] args) {

    PhoneBookArrayList bookArrayList = new PhoneBookArrayList();
    PhoneBookEntry entry1 = PhoneBookEntry("Jack", "920-456-2345");
    PhoneBookEntry entry2 = PhoneBookEntry("Sam", "868-344-2345");
    PhoneBookEntry entry3 = PhoneBookEntry("George", "414-234-2345");
    PhoneBookEntry entry4 = PhoneBookEntry("Dimo", "608-049-2345");
    PhoneBookEntry entry5 = PhoneBookEntry("Jenny", "971-456-2345");
    List<PhoneBookEntry> phoneNumberEntries = new ArrayList<>();
    phoneNumberEntries.forEach(number -> System.out.println(number));


PhoneBookEntry [name=Jack, phoneNumber=920-456-2345]
PhoneBookEntry [name=Sam, phoneNumber=868-344-2345]
PhoneBookEntry [name=George, phoneNumber=414-234-2345]
PhoneBookEntry [name=Dimo, phoneNumber=608-049-2345]
PhoneBookEntry [name=Jenny, phoneNumber=971-456-2345]