java – NullPointerException:Collections. binarySearch(List <?extends T>,T,Comparator <?super T>)line:not available

Print this stack error "collections. Binarysearch (list , t, comparator ) line: not available"

int index = Collections.binarySearch(getEmails(),email,determineComparator());
     // Search where to insert

I think the e-mail (returned by getemails()) may be null, but it is instantiated as:

ArrayList<Email> emails= new ArrayList<Email>();

If you point out what you need, I can provide more details

Solution

Your getemails () implementation must return null Collections. Binarysearch can handle null comparators but cannot handle empty lists

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>