I have created a VF page with 2 button 1 for add inputtext 1 by 1 and 2nd to delete inputtext 1 by 1.
The process is working 1 am bale to add and delete. But when it came to last inputtext it through’s an error. For eg: If added 3 inputtext 1,2,3
I am able to delete 3,2 but when i delete 1st when it through’s an error
List index out of bounds: 1
here is my code
public PageReference cancel() {
system.debug('@@@@@@@@@@@@@@@@@@@ eqLstNew Out ' + eqLstNew.size());
integer i =0;
if( i<eqLstNew.size()){
i++;
system.debug('@@@@@@@@@@@@@@@@@@@ eqLstNew 1st ' + eqLstNew.size());
system.debug('@@@@@@@@@@@@@@@@@@@ i size ' + i);
eqLstNew.remove(i);
}
return null;
}
can anybody find the solution and tell me what is wrong in the code.
Thanks
Anu
Make the
i++call at the end of theif:But I don’t understand why you are using a variable for this. If you always want to return the first element you should write it like this. Using an extra variable (which always has the same value) makes it more complicated.