我已经有了解决方案,但我想要一个更专业的解决方案。这是:
private boolean modelContains(Object[] product, DefaultTableModel model) {
boolean contains = false;
for(int i = 0; i < model.getRowCount(); i++) {
if(product[1].equals(model.getValueAt(i, 1))) {
System.out.println(product);
contains = true;
}
}
return contains;
}