Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9174077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:41:42+00:00 2026-06-17T16:41:42+00:00

i am facing ArrayIndexOutOfBoundsException in sorting. my code is here: Collections.sort(mutualFriends, new Comparator<FriendInfo>() {

  • 0

i am facing ArrayIndexOutOfBoundsException in sorting.
my code is here:

Collections.sort(mutualFriends, new Comparator<FriendInfo>() {
   public int compare(FriendInfo s1, FriendInfo s2) {
       return s1.name.compareToIgnoreCase(s2.name);
   }
});

Logs are here:

    STACK_TRACE=java.lang.ArrayIndexOutOfBoundsException
    at java.util.Collections.sort(Collections.java:1970)
    at com.platinumapps.fragments.Mutual_Friends_Fragment$1.onComplete(Mutual_Friends_Fragment.java:138) 
    at com.platinumapps.facedroid.AsyncRequestListener.onComplete(AsyncRequestListener.java:59) 
    at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:328)

and my my mutual friendlist is as:

private List<FriendInfo> mutualFriends = new ArrayList<FriendInfo>();

Any idea to fix this issue. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:41:42+00:00Added an answer on June 17, 2026 at 4:41 pm

    You are most likely having a data race in here.

    Some other thread tries to modify the list while it is being sorted (or accesses) – and you get a race condition, which causes in your case the IndexOutOfBoundsException.

    It is hard to know where exactly the problem is but some generic ways to solve it are:

    1. Make sure your code is thread safe. It can be easily done by
      synchronizeding on the ArrayList object everywhere it is
      being used –
    2. Use a class that is designed for thread-safety.

    A common bug that might be the issue in your case is spawning threads, and not waiting for them to finish their work before sorting. This can be solved by simply invoking join() on all threads before assuming they are done – this ensures you don’t continue until all threads are done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im facing a problem regarding my .htaccess file here is the code within the
Iam facing problem in understanding and converting a matlab code into opencv. I want
iam facing problem in passing array to view. this is my controller code.. function
Facing the following error: [Error] PLS-00049 (12: 11): PLS-00049: bad bind variable 'NEW.OPTION_D' I
I'm facing a change event not firing issue on Backbone.js =/ Here my view
Facing problem with every fetch i want to make using EF Query model.Place here
I facing a weird problem here. I already have a simple try-out for jquery
Im facing the following problem: public class StatCounterService extends Service { private TimerTask updateTask_ref
I'm facing a trouble with my href which is listed inside yui menu. Here
Facing some issue in Talend Admin Console, the jobs that are running from IDE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.