title: Checking if ArrayList element exists or not
body: <p>I'll try to explain this as best I can.  I have an ArrayList of String's.  I am trying to implement server-side paging for a webapp.  I am restricted to the number of items per page (6 in this case) which are read from this ArrayList.  The ArrayList is, lets say, the entire catalog, and each page will take a section of it to populate the page.  I can get this working just fine when there are enough elements to fill the particular page, its when we hit the end of the ArrayList where there will be less than 6 items remaining for that pages segment.  How can I check if the ArrayList is on its last element, or if the next one doesn't exist?  I have the following code (in pseudo-ish code):</p>
  
  <pre><code>int enterArrayListAtElement = (numberOfItemsPerPage * (requestedPageNumber - 1));
  for (int i = 0; i &lt; numberOfItemsPerPage; i++) {
      if (!completeCatalog.get(enterArrayListAtElement + i).isEmpty() {
          completeCatalog.get(enterArrayListAtElement + i);
      }
  }
  </code></pre>
  
  <p>The <strong>if</strong> in the code is the problem.  Any suggestions will be greatly appreciated.</p>
  
  <p>Thanks.</p>