我是将数组封装为类的。 其中方法说明:getmax(){ //计算数据个数。getData(int index)得到index的元素。setData(int index,int b)设置索引为index的元素值为b.
public void noDup(){
//循环嵌套将重复的设为-1
int max = this.getmax();
for(int i = 0;i < max;i ++){
for(int j = i + 1;j < max;j ++ ){
if (this.getData(i) == this.getData(j)) {
this.setData(i, -1);
}
}
}
}
//删除value为x的所有项
public void dele(int x){
int i = 0;
int max = this.getmax();
while(!(this.getData(i) == 0)){
if (this.getData(i) == x) {
for(int j = i;j < max;j ++){
this.setData(j, this.getData(j + 1));
}
}else{
i++;
}
}
}
作者 zhai4902176
http://www.dengb.com/Javabc/544273.htmlwww.dengb.comtruehttp://www.dengb.com/Javabc/544273.htmlTechArticle我是将数组封装为类的。 其中方法说明:getmax(){ //计算数据个数。getData(int index)得到index的元素。setData(int index,int b)设置索引为index的元素...