Can I add a group of ArrayList into a single ArrayList?

I hope I understand your question correctly An ArrayList is a list of Object types. If you wish to add an ArrayList as the item in your ArrayList, then you can do this An example ArrayList list = new ArrayList(); ArrayList list2 = new ArrayList(); ArrayList list3 = new ArrayList(); list. Add(list2); list.

Add(list3) This will result in your first ArrayList (list) containing two arraylists in position 0 and 1 If however you are looking to add the contents of several ArrayLists to a single list of elements, then you use addAll on the ArrayList. Such as ArrayList consolidatedList = new ArrayList(); list. AddAll(list2); list.

AddAll(list3).

I hope I understand your question correctly. An ArrayList is a list of Object types. If you wish to add an ArrayList as the item in your ArrayList, then you can do this.An example ArrayList list = new ArrayList(); ArrayList list2 = new ArrayList(); ArrayList list3 = new ArrayList(); list.

Add(list2); list. Add(list3); This will result in your first ArrayList (list) containing two arraylists in position 0 and 1. If however you are looking to add the contents of several ArrayLists to a single list of elements, then you use addAll on the ArrayList.

Such as ArrayList consolidatedList = new ArrayList(); list. AddAll(list2); list. AddAll(list3).

I didn't actually get what you want to do. Do you want to add all elements from different ArrayLists to one resulting ArrayList? If so, use ArrayList#addAll(Collection collection) method.

If you want an ArrayList of ArrayLists, use ArrayList#add(Object o) method. You can also parameterize your resulting ArrayList like this: List res = new ArrayList().

Yes you can add a "group of ArrayLists" into a single array list. If you want to "recognize" your ArrayLists, I would recommend using a Map, a HashMap for example. Please also think about accepting answers to your other questions, and post code in your questions, you will get better help and people will hate you less.

If so, use ArrayList#addAll(Collection collection) method. If you want an ArrayList of ArrayLists, use ArrayList#add(Object o) method.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions