我的要求是根据该 bean 中的customername
属性对 Customer 类型的 bean 列表进行排序......因为我使用了它。当字段不是beancomparator
时它工作正常。当场是投掷时..请帮帮我..customername
null
NullPointerException
null
我的代码是
public class customer{
private String customername;
}
main()
{
list<customer> list=new arraylist();
//list is filled with customertype beans
comparator<customer> comp=new beancomparator(customername);
collections.sort(list,comp);//throwing error when customername is null...
}