If you want the elements of book, newspaper and magazine ArrayLists will appear in one ArrayList resources, then you can make use of ArrayList.addAll(Collection) function: Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator.
resources.addAll(book);
resources.addAll(newspaper);
resource.addAll(magazine);
You want to create an ArrayList which will contain the ArrayLists as element:
ArrayList<ArrayList<String>>resources = new ArrayList<>();
resources.add(book);
resources.add(newspaper);
resources.add(magazine);
Assumed that the type of book, magazine and newspaper ArrayLists is ArrayList<String>. However, if second one is your target then i think it is better you declare resources as an HashMap<String, ArrayList<String>>.
HashMap<String, ArrayList<String>>resources = new HashMap<>();
// replace String with the type of the elements of book\newspaper\magazine
resources.put("book", book);
resources.put("newspaper", newspaper);
resources.put("magazine", magazine);
ArrayList<Resource> books = new ArrayList(); ArrayList<Resource> magazines = new ArrayList(); ArrayList<Resource> newspapers = new ArrayList();Actually I have an abstract class calledResourceand three extended classesBook,Newspaper,Magazine. I need an efficient way to iterate through all arrays.