import java.util.ArrayList; public class ExtArrayList extends ArrayList { public ExtArrayList slicer(int start, int count) { ExtArrayList extArrayList = new ExtArrayList(); if (start >= 0) { if (count + start > 20 || count < 0) { //ask about when count is less than 0 bc idk what the documentation means for (int i = start; i < 20; i++) { extArrayList.add(get(i)); } } else { while (count > 0) { extArrayList.add(get(start++)); count--; } } } else { int newStart = size() + start; while (count > 0) { extArrayList.add(get(newStart++)); count--; } } return extArrayList; } public static void main(String[] args) { ExtArrayList numbersList = new ExtArrayList(); for (int i = 1; i <= 20; i++) { numbersList.add(i); } ExtArrayList slicedOutput = numbersList.slicer(-3,2); System.out.println(slicedOutput); } }