title: How to implement subList() in Custom ArrayList
body: <p>I'm implementing my own generic ArrayList and everything is fine, but I've got a problem with the last method -  List subList(int fromIndex, int toIndex). I've tried to implement it, but still, I only create a copy of my main list and modify only it. My current code is</p>
  <pre><code>public List&lt;T&gt; subList(int fromIndex, int toIndex) {
          if (fromIndex &lt; 0 || toIndex &gt; size() || fromIndex &gt; toIndex)
              throw new IndexOutOfBoundsException();
          Object subarray[] = new Object[toIndex - fromIndex];
          for (int i = 0; i &lt; subarray.length; i++) {
              subarray[i] = array[fromIndex + i];
          }
          List&lt;T&gt; subList = Arrays.asList((T) subarray);
      return subList;
  }
  </code></pre>
  <p>I've also tried to do it using ArrayList instead of an array, but it still doesn't work (modify only my new subList instead of the whole list). How can I repair it? Do I have to implement another class?</p>
  <p>EDIT
  I also add my test method, I still get failure (the value in main list isn't changed)</p>
  <pre><code>@Test
      void subListWithoutNulls() {
          CustomArrayList&lt;Integer&gt; array = new CustomArrayList&lt;&gt;();
          array.add(3);
          array.add(7);
          array.add(2);
          array.add(5);
          array.add(8);
          array.add(3);
          array.subList(1, 4).set(0, 12);
          assertEquals(12, array.get(1));
      }
  </code></pre>