我的要求是根据customername该bean中的属性对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...
}
Run Code Online (Sandbox Code Playgroud) java ×1