title: Efficient way to divide a list into lists of n size
body: <p>I have an <code>ArrayList</code>, which I want to divide into smaller <code>List</code> objects of <code>n</code> size, and perform an operation on each.
  My current method of doing this is implemented with <code>ArrayList</code> objects in Java. Any pseudocode will do.</p>
  <pre><code>    for (int i = 1; i &lt;= Math.floor((A.size() / n)); i++) {
              ArrayList temp = subArray(A, ((i * n) - n),
                      (i * n) - 1);
              // do stuff with temp
          }
  
      private ArrayList&lt;Comparable&gt; subArray(ArrayList A, int start,
                  int end) {
              ArrayList toReturn = new ArrayList();
              for (int i = start; i &lt;= end; i++) {
                  toReturn.add(A.get(i));
              }
              return toReturn;
          }
  </code></pre>
  <p>where <code>A</code> is the list and <code>n</code> is the size of the desired lists</p>
  <p>I believe this way is taking too much time when working with considerably large lists of up to 1 million in size, so I'm trying to figure out what would be more efficient.</p>