0

I'm running on Netbeans 8.0.2 and I don't know I can't use the Collections.sort(), I have this error.

The type of Sort(Comparator<? super E> is erroneous where E is a type-variable : E extends object declared in class ArrayList

Example of code :

private void chargeData(String fileName) {
    base.ArticleDao.listeArticles = base.ArticleDao.getListeArticles(fileName);
    base.ArticleDao.listeArticles.sort(null);
    //Collections.sort(listeArticles);
    for (int i = 0; i < base.ArticleDao.listeArticles.size(); i++) {
        lstArticles.add(base.ArticleDao.listeArticles.get(i).toString());
    }
}//chargeData

I'm using Collections.sort() in order to.... sort my arrayList but I have this error, even I do :

myArrayList.sort(null) in order to use compareTo().

Do you have some ideas for the configuration on netbeans ? I tested on my school computer, and it was worked.

Thank you for taking time on my problem and have a nice day full of code =)

9
  • Collections.sort(myArrayList); is not the same as myArrayList.sort();. Commented Jan 12, 2017 at 20:55
  • What's the code? Most likely it's an error in the code, as Netbeans itself is just an IDE. Commented Jan 12, 2017 at 20:55
  • Is an ArrayList not a collection ? I tested those two ways and the sort worked. Commented Jan 12, 2017 at 20:56
  • @Paul Here is a little part of my code =) Commented Jan 12, 2017 at 20:59
  • @Arkhall I meant the code where you call Collections.sort(). Commented Jan 12, 2017 at 21:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.