这就是我现在所拥有的:
public ArrayList subList(int fromIndex, int toIndex){
ArrayList a = new ArrayList();
for (int i=fromIndex;i<toIndex;i++) {
a.add(stuff[i]); //stuff is a array of strings
}
return list;
}
但是是否可以在不创建新数组的情况下返回子列表?我被限制使用 Array/ArrayList 类中的任何方法。