title: Sublist Arraylist in android
body: <p>I want to sublist an arraylist and store it in small arraylists.</p>
  
  <p>I am doing as following but unable to enter exact values in the small arrays.Please see my code and suggest some other way or tell me what i am doing wrong </p>
  
  <pre><code>ArrayList&lt;ques_details&gt; queslist = new ArrayList&lt;ques_details&gt;();
  
  ArrayList[] resgrp = new ArrayList[queslist.size() / 2];
  Log.v("length", resgrp.length + "");
  
  for (int i = 0; i &lt; resgrp.length ; i++) {
      resgrp[i] = new ArrayList();
      Log.v("initialised ", i + "");
  }
  
  for (int i = 0; i &lt;= queslist.size()-1 ; i++) {
      resgrp[i].add(queslist.get(i));
      Log.v("final ", resgrp[i].size() + "");
  }
  </code></pre>
  
  <p><strong>EDIT :</strong></p>
  
  <pre><code>public void subListArray(int start, int end) {
          // Log.v("queslist size", queslist.size() + "");
          int m = queslist.size();
          // Log.v("m", m + "");
          ArrayList[] resgrp = new ArrayList[m / 2];
          // Log.v("length", resgrp.length + "");
          int n = resgrp.length;
          // Log.v("n", n + "");
          int o = m / n;
          // Log.v("o", o + "");
          for (int i = 0; i &lt; n; i++) {
              resgrp[i] = new ArrayList&lt;String&gt;();
              Log.v("initialised ", i + "");
          }
          ArrayList&lt;String&gt; TempList = new ArrayList&lt;String&gt;();
          for (int i = start; i &lt;= end - 1; i++) {
              int q = 0 ;
              String temp = queslist.get(i).Ques;
              resgrp[o].add(q, temp);
              // resgrp[i].add(queslist.get(i));
              Log.v("final ", queslist.get(i).Ques + "");
              TempList = resgrp[o];
              q++;
              adapter = new ArrayAdapter(E_Learning_AppActivity.this,
                      R.layout.list_item, R.id.text, TempList);
          }
      }
  </code></pre>