So I have a class called Persons that the moment has a method to add Person objects when created in main.
import java.util.*;
public class Persons {
public ArrayList<Person> personsList = new ArrayList<Person>();
public boolean addPerson(Person newPerson) {
personsList.add(newPerson);
return true;
}
}
This is my main method
import java.util.*;
public class testPersons {
public static void main(String[] args) {
Persons persons = new Persons();
Address person1Address = new Address(xxx, "xxx", "xxx", "CA", "xxx");
Address person1JobAddress = new Address(1542, "High St", "Santa Cruz", "CA", "94063");
ArrayList<String> person1Phone = new ArrayList<String>();
person1Phone.add("xxx-xxx-xxx");
Job person1Job = new Job("Teacher", 25000.00, person1JobAddress);
Person person1 = new Person("xxxxxxx", "San Mateo", 'M', person1Address, person1Job, person1Phone);
persons.addPerson(person1);
System.out.println(persons);
}
}
So my question is, "How would I add the object Persons1 into my arrayList in Persons class?" It does compile, but I when run it, I get weird gibberish. Would it be I'm missing something in my Persons class, main or can I not print the objects in ArrayList like I did?