最好的选择是使用对象集合。元素被复制到同一数组,位置偏移量为 -1.
public void removeElement(Object[] a, int del) {
System.arraycopy(a,del+1,a,del,a.length-1-del);
}
Apache Commons
你也可以使用commons lang的libraryArrayUtils.array = ArrayUtils.removeElement(array, element)Resources:
https://stackoverflow.com/questions/642897/removing-an-element-from-an-array-java
Commentaires (0)
Laisser un commentaire
Connectez-vous pour commenter
Rejoignez la discussion et partagez vos connaissances avec la communauté
Chargement des commentaires...