DESKTOP-7D2I5KK_20200907-郎航
问题
public Object remove( int index ) {
Object old = elements[ index ];
System.arraycopy( elements , index + 1 , elements , index , counter - index );
counter-- ;
return old ;
}
public void remove( Object o ) {
int index = this.indexOf( o );
if( index != -1 ) {
this.remove( index );
}
}
解决
第一个是删除指定索引处的元素并返回该元素;
第二个是删除指定的元素;
第二个还调用了上一个索引的方法。
吐槽
就挺难的!!!
近期评论