0

I have to make a small app as an class exercise which simulates an mobile phone which is able to add and list contacts.

In the main I have to create a new mobile phone by its brand and to add new contacts in it. How can I make an ArrayList which stores the contacts and add them in the List as it follows ?

public static void main(String[] args) {

    Phone phone = new GalaxyS6();//should compile

    phone.addContact("id", "phoneNumber", "firstName", "lastName");
3
  • What is the language used? Commented Nov 19, 2018 at 20:20
  • Java is the language. Commented Nov 19, 2018 at 20:22
  • What do you mean by make "make an ArrayList which stores the contacts and add them in the List as it follows " ? Can you be more specific, so that its easy to answer? Commented Nov 19, 2018 at 20:42

1 Answer 1

0

If you want to add the objects to the arraylist, Create the arraylist of your class type and you can add it something like this,

   ArrayList<Phone> phoneList = new ArrayList<>();
   phoneList.add(new phone("id", "phoneNumber", "firstName", "lastName"));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.