delete item from array in java
Posted
by davit-datuashvili
on Stack Overflow
See other posts from Stack Overflow
or by davit-datuashvili
Published on 2010-05-14T07:10:54Z
Indexed on
2010/05/14
7:24 UTC
Read the original article
Hit count: 208
algorithms
|java
hello can anybody tell me what is wrong here? i want delete item from array but it shows me
error ArrayIndexOutBound exception
public class delete{
public static void main(String[]args){
int i;
//delete item from array
int k[]=new int[]{77,99,44,11,00,55,66,33,10};
//delete 55
int searchkey=55;
int nums=k.length;
for ( i=0;i<nums;i++)
if (k[i]==searchkey)
break;
for (int t=i;t<nums;t++)
k[t]=k[t+1];
nums--;
for (int m=0;m<nums;m++){
System.out.println(k[m]);
}
}
}
© Stack Overflow or respective owner