I am looking for a Java (Android) method to add a new element after every n items. The example is as following: I have two different types of items implementing same base class, let's say A and B. What I would like to achieve is to add item from an array (of B elements) to another array (of A elements) after every, let's say, 10 items. I can achieve it by implementing loop logic, but looking for some built-in functionality. Thank for your help.
DETAILS:
ArrayList<A> aList = new ArrayList<A>(Arrays.asList(a, a, a, a, a, a, a));
ArrayList<B> bList = new ArrayList<B>(Arrays.asList(b, b, b);
What I would like to achive is add element from "bList" to "aList" after every 3rd element of "aList" without replacing items in "aList". So my desired ArrayList is like:
ArrayList<A> aList = new ArrayList<A>(Arrays.asList(a, a, a, b, a, a, a, b, a, b));