title: How to limit ArrayList to 15?
body: <p>I have 2 array lists. i iterate through list1 and store the data that matches the seat_no to the index of list2.</p>
  
  <p>list1 contains:</p>
  
  <pre><code>|seat_no | id     |
  ===================
  | 1      | 001    |
  | 2      | 002    |
  | 3      | 003    | 
  | 4      | 004    |
  | 7      | 005    |
  | 10     | 006    |
  | 11     | 007    |
  </code></pre>
  
  <p>list2 contains:</p>
  
  <pre><code>|index   | id     | seat_no |
  =============================
  | 1      | 001    | 1       |
  | 2      | 002    | 2       |
  | 3      | 003    | 3       |
  | 4      | 004    | 4       |
  | 5      |"blank" |"blank"  |
  | 6      |"blank" |"blank"  |
  | 7      | 005    | 7       |
  | 8      |"blank" |"blank"  |
  | 9      |"blank" |"blank"  |
  | 10     | 006    | 10      |
  | 11     | 007    | 11      |
  </code></pre>
  
  <p>what list2 should contain:
  where list2 must have a limit of 15</p>
  
  <pre><code>|index   | id     | seat_no |
  =============================
  | 1      | 001    | 1       |
  | 2      | 002    | 2       |
  | 3      | 003    | 3       |
  | 4      | 004    | 4       |
  | 5      |"blank" |"blank"  |
  | 6      |"blank" |"blank"  |
  | 7      | 005    | 7       |
  | 8      |"blank" |"blank"  |
  | 9      |"blank" |"blank"  |
  | 10     | 006    | 10      |
  | 11     | 007    | 11      |
  | 12     |"blank" |"blank"  |
  | 13     |"blank" |"blank"  |
  | 14     |"blank" |"blank"  |
  | 15     |"blank" |"blank"  |
  </code></pre>
  
  <p>Here's my code so far... pls help me.. i plan to use array but i don't know if its applicable to my codes now.. </p>
  
  <p>ViewGridObject.java</p>
  
  <pre><code>public class ViewGridObject 
  {
      public String stud_id, seat_no;
  
      public ViewGridObject(String stud_id, String seat_no)
      {
          this.stud_id = stud_id;
          this.seat_no = seat_no;
      }
  }
  </code></pre>
  
  <p>main.java</p>
  
  <pre><code>ArrayList&lt;HashMap&lt;String, String&gt;&gt; to_take = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
          try 
          {
              JSONObject jArray = new JSONObject(result);
  
              JSONArray stud_info = jArray.getJSONArray("stud_info");
  
              ca_list = new ArrayList&lt;ViewGridObject&gt;();
  
              for (int i = 0; i &lt; stud_info.length(); i++) 
              {
                  HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                  JSONObject e = stud_info.getJSONObject(i);
  
                  map.put("id", String.valueOf(i));
                  map.put("stud_id", e.getString("student_id"));
                  map.put("seat_no", e.getString("seat_no"));
                  to_take.add(map);
  
                  ca_list.add(new ViewGridObject(e.getString("student_id"), e.getString("seat_no")));
  
  
              }
  
              List&lt;ViewGridObject&gt; list2 = new ArrayList&lt;ViewGridObject&gt;();
              int i1 = 0;
              for (ViewGridObject o : ca_list) {
                  for (i1++; !o.seat_no.equals(i1 + ""); i1++) {
                      list2.add(new ViewGridObject(null, 0, i1 + ""));
                  }
                  list2.add(o);
              }
  </code></pre>