java – NullPointerException:Collections. binarySearch(List <?extends T>,T,Comparator <?super T>)line:not available
•
Java
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
二维码