0

Is we can add multiplye values at a single index in arraylist??

Basically, I want to add contact details of different person eg. Name, contact number, email etc. So is I can store all the things related to single person on one index value or not?

7th May 2020, 11:48 AM
Muhammad Bilal
Muhammad Bilal - avatar
3 odpowiedzi
+ 2
Yes you can. Just like CarrieForle has mentioned, all you need to do is create a class and pass the objects to the list. List<Person> list = new ArrayList<Person>(); list.add(new Person(name,contact,email)); Something similar.
7th May 2020, 12:10 PM
Avinesh
Avinesh - avatar
+ 1
You can make a class "person" with attributes that a person has, and store the objects of the class in the arraylist.
7th May 2020, 11:59 AM
你知道規則,我也是
你知道規則,我也是 - avatar
0
Ok got it. thanks both of you.
7th May 2020, 12:11 PM
Muhammad Bilal
Muhammad Bilal - avatar