How do I remove a value from an array by putting -1 in place, and return the next index that has a value to be removed? Since this function should already return a position that has a value to be removed, I would not need to either verify and only point to the next position that has a value. If the value is there, I remove it by putting -1 to indicate it is empty.
This function should remove the letter, and indicate the next empty index, but when I give a print it indicates positions that have -1.
int removeCard(int[] arrCards, int topPonteiro) {
if(arrCards[topPonteiro] != -1){
arrCards[topPonteiro]=-1;
topPonteiro=(topPonteiro+1)%arrCards.length;
}
return topPonteiro;
}