This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

ConcurrentModificationException  RSS feed

Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got this error java.util.ConcurrentModificationException
how to solved this problem

package com.gate;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ConcurrentModificationException;

import android.R.integer;
import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.view.View.OnTouchListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Toast;

public class MainEdtShifting extends Activity {

private Button btnexit,btnback,btnSearch,BtnSave,BtnReset;
ProgressDialog pDialog;
JSONArray dataJSON = null;
ArrayList<SetterGetter> tampung ;
ArrayList<SetterGetter> tampungdetail ;
ArrayList<SetterGetter> tampungspin ;
AutoCompleteTextView txtNoContainer ;
DataAdapter adapter;
static EditText EdtTglShiftting;
private int hit;
EditText txtBlock,txtRow,txtCol,txtStack ;
EditText txtBlock1,txtRow1,txtCol1,txtStack1 ;
ListView lv;

private static final String url_update_container = "";
private static final String TAG_NoContainer = "NoContainer";
private static final String TAG_Block = "Block";
private static final String TAG_Row = "Row";
private static final String TAG_Col = "Col";
private static final String TAG_Stack = "Stack";
private static final String TAG_SUCCESS = "success";
private static final String TAG_userlogin = "userlogin" ;
private int success = 0 ;

private String userlogin;
private Spinner spinner_condition ;

   protected void onCreate(Bundle savedInstanceState) {
       Intent dapatdata = this.getIntent();
userlogin = dapatdata.getStringExtra("userlogin");

tampung = new ArrayList<SetterGetter>();
txtNoContainer = (AutoCompleteTextView) findViewById(;
       new GetDataKontainer().execute();

public class GetDataKontainer extends AsyncTask<String, String, String> {
 protected void onPreExecute() {
  pDialog = new ProgressDialog(MainEdtShifting.this);
  pDialog.setMessage("Loading Data...");

 protected String doInBackground(String... arg0) {    
 String url = "" ;
 Log.e("proses : ", "---------->" + url);
 JSONParser jParser = new JSONParser();
 JSONObject json = jParser.getJSONFromUrl(url);
 System.out.println(" tampung --------------> " + tampung);
  try {
  dataJSON = json.getJSONArray("list_container");
  System.out.println(" kesini --------------> ");
  for (int i = 0; i < dataJSON.length(); i++) {
JSONObject c = dataJSON.getJSONObject(i);

tampung.add(new SetterGetter(c.getString("cont_number"), c.getString("block_loc"), c.getString("rowss"), c.getString("col"), c.getString("stack"), "",c.getString("contstatus"))) ;


  } catch (JSONException e) {
  return null;
 protected void onPostExecute(String result) {  

List<SetterGetter> list = new ArrayList<SetterGetter>();

       for(SetterGetter karyawan:tampung){
        list.add(new SetterGetter(karyawan.getcontno().toString(), karyawan.getblock().toString(), karyawan.getrow().toString(), karyawan.getcol().toString(), karyawan.getstack().toString(),"",karyawan.getcontstatus().toString())) ;
        Iterator<SetterGetter> iter = list.iterator();
        SetterGetter str =;
        String AA = karyawan.getcontno().toString(); String BB = karyawan.getblock().toString();
            String CC = karyawan.getrow().toString(); String DD = karyawan.getcol().toString();
            String EE = karyawan.getstack().toString(); String FF = karyawan.getcontstatus().toString();
            String KK = str.getcontno().toString(); String LL = str.getblock().toString();
            String MM = str.getrow().toString(); String NN = str.getcol().toString();
            String OO = str.getstack().toString(); String PP = str.getcontstatus().toString();
            if(KK.equals(AA) && LL.equals(BB) && MM.equals(CC) && NN.equals(DD) && OO.equals(EE) && PP.equals(FF)){
        list.add(new SetterGetter(karyawan.getcontno().toString(), karyawan.getblock().toString(), karyawan.getrow().toString(), karyawan.getcol().toString(), karyawan.getstack().toString(),"",karyawan.getcontstatus().toString())) ;
        }catch (ConcurrentModificationException e) {
       txtNoContainer = (AutoCompleteTextView) findViewById(;
       adapter = new DataAdapter(MainEdtShifting.this, R.layout.frmeditshifting,, list);
       txtNoContainer.setText("") ;


[Thumbnail for ConcurrentModificationException.jpg]
Saloon Keeper
Posts: 5038
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem occurs in line 121 of the DataAdapter class, so we'd need to see the relevant part of that.

The relevant variable is probably the (not-too-well-named) "list", so you should start by examining where (and when) that is modified.
I was born with webbed fish toes. This tiny ad is my only friend:
Download Free Java APIs to Work with Office Files and PDF
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!