0
我有类如何使用BeanUtils的替代Java的ArrayList中元素的现有价值
class cust{
private String name;
private int id;
//Getter and setters
//equals
//hashcode
//toString
}
在我的主类
List<Customer> custList = new ArrayList<Customer>;
CUSTLIST具有独特的客户在它补充说。
如果我将新客户添加到列表中,我需要使用beanutils替换具有相同ID和ID的旧客户。
这是我的BeanUtils代码
BeanUtils.setProperty("customer", "custList[0]", customer);
PS:我已经重写等于& hashCode方法。
我实现只用BeanUtils的。为了更好的理解,我简化了上面的例子。 – Ijaz