My requirements are to sort the list of type Customer beans according to the property customernamein this bean ... for this I used beancomparator.it works fine when the field is customernamenot null. He throws NullPointerExceptionwhen the field null.. please help me.
my code
public class customer{
private String customername;
}
main()
{
list<customer> list=new arraylist();
comparator<customer> comp=new beancomparator(customername);
collections.sort(list,comp);
}
source
share