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 8546347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:59:50+00:00 2026-06-11T12:59:50+00:00

i keep getting concurrent modification exception String[] permsList = Constants.CUST_MKT_PERMS_FIELDS; String hiddenFieldVector = new

  • 0

i keep getting concurrent modification exception

String[] permsList = Constants.CUST_MKT_PERMS_FIELDS;
String hiddenFieldVector = new Vector<String>(permsList.length);
Iterator<String> itr = hiddenFieldVector.iterator();

for(int i = 0; i < arrayLength; i++){    //arrayLength is never null or 0

    ...a lot of code...
    String target = fromDatabase();     //this is never null

   while(itr.hasNext() && hiddenFieldVector.contains(target)){
    hiddenFieldVector.remove(target);
    Logger.debug("itr.next() = " + itr.next());
   }

    ...a lot of code...
}

any ideas why?

current solution:

while(itr.hasNext() && hiddenFieldVector.contains(target) && (itr.next().equals(target))){
                        itr.remove();
                        Logger.debug("itr.next() = " + itr.next());
                    }
  • 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-11T12:59:51+00:00Added an answer on June 11, 2026 at 12:59 pm
    hiddenFieldVector.remove(target);
    

    Dont call remove on list while looping. Modifying list while looping throws ConcurrentModificationException.

    Use iterator and call remove on iterator instead of list.

    Example:

    while(itr.hasNext() && hiddenFieldVector.contains(target)){
        itr.remove();
        Logger.debug("itr.next() = " + itr.next());
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

String input from keyboard Vector<String> myVector = new Vector<String>(someArray.length); //assume Vector is populated Iterator<String>
This is the error I keep getting. Exception in thread Thread-3 java.util.ConcurrentModificationException at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:782)
I keep getting this error with my Play 2.0 application: play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[MatchError:
I keep getting a Run Time error that says I am having an Exception
I keep getting stuck conceptually on deciding an Exception-handling structure for my project. Suppose
I keep getting a exception when I try to FTP to my Win 2008
I keep getting this error when I try to create a new instance of
I keep getting the exception NoSuchElement relative to my scanning of the .txt file.
I keep getting an exception when I want to display an alertdialog at the
Keep getting this error after inserting a subdatasheet into a query and trying to

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.