I have already tried two different methods but I have the same problem and I do not know how to delete items consecutively from my number array in BigInteger.
Here is the code:
BigInteger[] recov = null;
BigInteger del = new BigInteger(deleteTextField.getText());
int size = Integer.parseInt(sizeTextField.getText());
for (int i = 0; i < array.length; i++) {
int arrice = array[i].compareTo(del);
if(arrice==0){
recov = new BigInteger[array.length-1];
for (int index = 0; index < i; index++) {
recov[index] = array[index];
}
for (int j = i; j < array.length-1; j++) {
recov[j]=array[j+1];
}
break;
}
}
System.out.println("El vector eliminado es: ");
for (int i = 0; i < recov.length; i++) {
System.out.print("["+recov[i]+"]");
}
Where at the moment of deleting the first element I do not have any problem but if I erase consecutively the element is overwritten:
The random vector created is: [4] [42] [104] [99] [118]
By removing 104 from the vector, it looks like this: [4] [42] [99] [118] // With the first case I have no problem
When you delete 42 from the vector, it looks like this: [4] [104] [99] [118] // Recover 118
When you delete 4 from the vector, it looks like this: [42] [104] [99] [118]
When you delete 99 from the vector, it looks like this: [4] [42] [104] [118]
By removing 118 from the vector, it looks like this: [4] [42] [104] [99]
How can I eliminate them permanently?