Hello, I've been working on this code and think I have it working. The only issue is that I'm not getting the values of the array list. Instead I just get some weird text and numbers when I go to print the array list. The following is my code:
Personal Contacts Subclass
Business Contacts Subclass
And here is what prints out:
Can anyone point me in the right direction? I know I'm close, but I'm just not thinking about something and it's frustrating. Appreciate the assistance.
Thanks Manoj Kumar Jain. Would I have to override each of the get() methods, or just the displayContacts? I'm sorry for the greenhorn question, I'm just learning java and trying to understand when to do what, and what goes where.
No, you only have to override the method "public String toString()". And don't have it write the description of the Contact to the console, it should generate a String value and return it as the result of calling that method. Like Manoj said, every class has a toString() method which is inherited from Object, and overriding that to produce a useful description of an object is frequently a good thing to do.
Then change the displayContacts() method in the Contact class to simply write the result of toString() to the console. (By the way why is a class which is meant to represent a contact called "Contacts" and not "Contact"?)
Thanks for the clarification Paul Clapham. To answer your question, I was on my third or fourth iteration of scrapping and rewriting the program. I didn't want to delete my previous codes in case something was helpful, so I started renaming them, albeit subtle renaming, so I would look at the classes more carefully and know if I was working on the right one.