public IntegerList sublist(Integer leftBoundary, Integer rightBoundary) {
   IntegerList sublist = createEmptyInstance();
   for (int i = leftBoundary; i <= rightBoundary; i++) {
     sublist.append(this.get(i));
   }
   return sublist;
 }
 @Test
 public void testAddToTail() {
   IntegerList list = new IntegerList(5);
   list.addToTail(6);
   assertEquals(6, list.getTailValue());
   assertEquals(5, list.getHeadValue());
 }
 @Test
 public void testGetSize() {
   IntegerList list = new IntegerList(5);
   list.addToTail(6);
   list.addToHead(7);
   list.addToTail(8);
   assertEquals(4, list.getSize());
 }
  @Test
  public void testGetTailValue() {
    IntegerList list = new IntegerList(5);
    list.addToTail(6);
    list.addToTail(7);

    assertEquals(7, list.getTailValue());
  }
  @Test
  public void testEqualsObjectEqual() {
    IntegerList list = new IntegerList(5);
    list.addToTail(6);
    list.addToHead(7);
    list.addToTail(8);

    IntegerList list2 = new IntegerList(5);
    list2.addToTail(6);
    list2.addToHead(7);
    list2.addToTail(8);

    assertTrue(list.equals(list2));
  }
 @Override
 public boolean equals(Object thatObject) {
   if (thatObject == null) {
     return false;
   }
   if (!thatObject.getClass().isAssignableFrom(this.getClass())) {
     return false;
   }
   IntegerList that = (IntegerList) thatObject;
   if (this.size() != that.size()) {
     return false;
   }
   for (int i = 0; i < this.size(); i++) {
     if (!this.get(i).equals(that.get(i))) {
       return false;
     }
   }
   return true;
 }
  @Test
  public void testContains() {
    IntegerList list = new IntegerList(5);
    list.addToTail(6);
    list.addToHead(7);
    list.addToTail(8);
    assertTrue(list.contains(5));

    assertTrue(list.contains(6));

    assertTrue(list.contains(7));

    assertTrue(list.contains(8));

    assertFalse(list.contains(42));
  }
  @Test
  public void testGetHeadValue() {
    IntegerList list = new IntegerList(5);

    assertEquals(5, list.getHeadValue());
  }