URGENT HELP REQUIRED!!! - 'deleting' element from array
Hi
i have written the following method and am wondering if some of the more skilled and knowledgable (more than me i mean) java'ers can check it out and tell me why the value of poss isnt changing as it should:
/* the general idea is that a name of a client is provided to the program,
it should search the arrray, find the client, store their index in poss,
then, starting from poss moving farwards through the array it should
copy the elements back 1 space to write over the 'deleted' client, then to
eliminate the duplicate element on the end transfer it to an array with 1
less space, however, apon debugging i have discovered that poss
doesnt change when the client IS found, i know the client is there as i
entered it myself, can someone tell me why its not finding the client and
storing their index value?*/
publicstaticvoid deleteClient (String name)
{
Client[]c2;
c2 =new Client[c.length-1];
int poss=-1;
for (int i=0;i<noClients;i++)
{
if ((c[i].getName()) == name)
{
poss = i;
}
}
if(poss==-1)
{
System.out.println("Client does not exist");
}
else
{
for (int i=poss;i<noClients;i++)
{
c[i]=c[i+1];
}
}
c2=c;
c=c2;
}
PS; i am not allowed to use Array List for this task unfortunately, so i am stuck with the old stlye Array
Cheers for any help>

