I have a problem with this code, I have 5 Product objects in a table set by default and I have multiple selection mode set for the table. When I select all the 5 items and try to delete them, there are two of them which are not deleted.

the delete method code:
private void deleteButtonClicked() {
ObservableList<Product> productsSelected = table.getSelectionModel().getSelectedItems();
ObservableList<Product> allProducts = table.getItems();

for (Product product : productsSelected) {
allProducts.remove(product);
}
}