Results 1 to 2 of 2
  1. #1
    deshmukhmp is offline Member
    Join Date
    Nov 2011
    Rep Power

    Default Regarding map ina java

    I have to get the frequency count of each integer in a numeric string further to remove least occured element based on the support value provided as a parameter to the following function from the map

    the following is the code

    public void discardentry(int support)
    Iterator it = m.entrySet().iterator();
    while (it.hasNext()) {
    Map.Entry pairs = (Map.Entry);
    if(Integer.parseInt((pairs.getValue()).toString()) <support)


    I'm receiving the exception named concurrent modification.
    let me know the code for given a map to compare given value with a map value and to remove the entries from the map which are having less value than a given value

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Regarding map ina java

    You are trying to remove an entry from your map 'behind the back' of the iterator, hence the Exception. A map keeps a 'modifiation counter' and increments it each time the map is modified. When an Iterator is instantiated it registers this modification count. Each time an Iterator has to do something it compares the map's modification counter and its own version; when they differ the map was modified 'behind the back' of the Iterator and it throws an Exception. Read the API for the Iterator interface: an Iterator can (optionally) remove an entry from the Collection it iterates over ...

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts