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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:46:43+00:00 2026-05-22T12:46:43+00:00

Hi I am creating two lists to hold good and bad data values. I

  • 0

Hi I am creating two lists to hold good and bad data values.
I pass these lists to a method where I add a new key value to the goodMap, check some conditions on the record if it is not good then add that record to the bad file and remove it from the good File ,but I recieve oncurrentModificationException while doing so. How do i Fix this?

Pseudocode

    //original Lists of users
    List<Map<Object, Object>> _goodFile
    List<Map<Object, Object>> _badFile

    //tempList to hold return value
    List<Object> _tempList=new ArrayList<Object>(1);



    //call the method
    _tempList=cleanMap(_goodFile,_badFile)

     //assign the values back to original list
    _goodFile=_tempList.get(0);
    _badFile=tempList.get(1);


    //this is the method for cleaning

    public List<Object> cleanMap ( List<Map<Object, Object>> _temp1, List<Map<Object, Object>> _temp2)

    {

//return List

 List<Object> _returnList =new ArrayList<Object>(1);


for (Iterator<Map<Object, Object>> i = _temp1
                    .iterator(); i.hasNext();) 

            {
    Map<Object, Object> _Record = i.next();

     //first add a new key value pair to goodFile map
    _Record.put("Key","value");

    // check for condition; if it is bad remove from list

    if (bad)
    {
    //first add in bad file
    _temp2.add(_Record);

    //then remove from good file
    _temp1.remove(_Record);
    }

             }

return _returnList;

    }
  • 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-05-22T12:46:44+00:00Added an answer on May 22, 2026 at 12:46 pm

    Instead of doing this:

    _temp1.remove(_Record);
    

    try doing this:

    i.remove();
    

    See the javadoc for Iterator.remove.

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

Sidebar

Related Questions

I am creating a new database to manage wish lists. Solution A: Two tables,
I need UNION two tables with creating new field, where 1 for first table,
I'm creating a ListView that contains two TextViews and an ImageView. I'm passing data
I'm creating JSON encoded data from PHP arrays that can be two or three
I have these two lists: '(and 1 (or a b)) '( (a 0)(b 1)
I'm creating a server control that basically binds two dropdown lists, one for country
Essentially, I am just creating two classes where one class, in this case class
I am creating a registration form which contains two submit buttons. I need to
hey I'm creating an app with two switches on it that change the background
I'm creating a bundle for Symfony 2 that has two user types. Only one

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.