when i try to remove element there is an error, i have uploaded the error in the image section. any help to fix? of any other way to get the code fixed and working smoothly and it it works while deleting the middle element not the first or second duplication issue ,fixed using iterator. hatsooff to stack overflow . all good  import java.util.*;  public class EarthquakeList { private ArrayList&lt;EarthquakeNode&gt; records;  public EarthquakeList() {    records = new ArrayList&lt;EarthquakeNode&gt;();  }  public boolean isempty() {       return true; }   public void add(String EarthquakeLo,String EarthquakeDt, double EarthquakeSgth, int EarthquakeDu) {    EarthquakeNode en = new EarthquakeNode(EarthquakeLo, EarthquakeDt, EarthquakeSgth, EarthquakeDu);    records.add(en); }   public boolean remove(String EarthquakeLo,String EarthquakeDt) {    boolean flag= false;    for(EarthquakeNode earthquake: records)    {        if(earthquake.getLocation().equalsIgnoreCase(EarthquakeLo))        {            if(earthquake.getDate().equals(EarthquakeDt))            {                records.remove(earthquake);                flag=true;             }        }    }    return flag;  }    public EarthquakeNode search(String EarthquakeLo,String EarthquakeDt) {    EarthquakeNode node= null;    for(EarthquakeNode earthquake: records)    {        if(earthquake.getLocation().equalsIgnoreCase(EarthquakeLo))        {            if(earthquake.getDate().equals(EarthquakeDt))            {                 node=earthquake;            }        }    }    return node; }   public boolean clear() {     int count=records.size();    for(EarthquakeNode earthquake: records)    {        count=count-1;        records.remove(earthquake);       }    if(count==0)    {    System.out.println("already empty");    return false;}     else     System.out.println("every thing is removed");    return true; }   public boolean isempty(String EarthquakeLo,String EarthquakeDt) {    boolean flag= false;    for(EarthquakeNode earthquake: records)    {        if(earthquake.getLocation().equalsIgnoreCase(EarthquakeLo))        {            if(earthquake.getDate().equals(EarthquakeDt))            {                flag=true;            }        }    }    return flag; }   public void print() {    for(EarthquakeNode earthquake: records)    {        System.out.println( earthquake.getLocation() +" - "               + earthquake.getDate()+ " - "                + earthquake.getStrength() + " on rector scale"+                "-" + earthquake.getDuration() + "mins");    }  }   }
We all know you can't do the following because of ConcurrentModificationException:  for (Object i : l) {     if (condition(i)) {         l.remove(i);     } }   But this apparently works sometimes, but not always. Here's some specific code:  public static void main(String[] args) {     Collection&lt;Integer&gt; l = new ArrayList&lt;&gt;();      for (int i = 0; i &lt; 10; ++i) {         l.add(4);         l.add(5);         l.add(6);     }      for (int i : l) {         if (i == 5) {             l.remove(i);         }     }      System.out.println(l); }   This, of course, results in:  Exception in thread "main" java.util.ConcurrentModificationException   Even though multiple threads aren't doing it. Anyway.  What's the best solution to this problem? How can I remove an item from the collection in a loop without throwing this exception?  I'm also using an arbitrary Collection here, not necessarily an ArrayList, so you can't rely on get.
"Activity" tab for the Community user's network profile sometimes leads to a server error How to monitor disk activity? How do I view my Disk Activity on Ubuntu? For example, How can I monitor what is being written and read from disk as well as the percentage of disk usage?  I am looking for an application similar to the Resource Monitor in Windows. I'hv seen every 2 pin SMPS AC to DC adapters shows a little high voltage respective to the ground on the out put, on both + and GND wires(or more if more wires present).  This voltage is high enough to light small neon bulbs or a line tester, but very low current, barely could be felt. This voltage vanishes if I connect the output to ground somehow, e.g. touch it while standing on floor bare foot.  As the size of the adapter increases, the AC voltage and current increases. When laptop adapters are powered from a ungrounded AC outlet, they gives reasonable shock from the 19V DC(or whatever else) output.  Perhaps this is the reason why many 3 pronged laptop adapter carries a warning CONNECT ONLY TO GROUNDED OUTLET Connecting to a grounded outlet magically vanishes the high voltage.  I am aware about the EMI filtering capacitor connected between high voltage and low voltage ground, I tried to solve this by removing them, but this trick is not working.   Why and how this mysterious AC voltage is created ?  Is it harmful to sensitive electronics components ? Is there any way to solve this without grounding the DC output side ? How to implement keyboard shortcuts on websites How to submit webform programmaticaly? What is the advantage of using sudo apt-get autoremove over a cleaner app? Is abstract algebra (mostly?) restricted to $2$-ary operators? Can $(X_1,X_2) \cap (X_3,X_4)$ be generated with two elements from $k[X_1,X_2,X_3,X_4]$? Can $(X_1,X_2) \cap (X_3,X_4)$ be generated with two elements in the ring $R=k[X_1,X_2,X_3,X_4]$? Can it be generated with three elements? (Here $k$ is a field.)    Thanks for any help. How to show wifi password? How to adjust the size and placement of chapter heading in report class How could I adjust the size and placement of chapter heading in my custom class? I am using report class as my base. When I used titlesec package inside my custom class, it threw error     ! Package titlesec Error: Not allowed in `easy'   settings. Keyboard layout/language changes in every boot I've come across the word litotes, which means a rhetorical understatement. However, I’m having trouble understanding how to use it in colloquial English. Could someone please give an example? Is there anything beyond subtle hints that Jack becomes the Face of Boe? Get current URL with jQuery? I am using jQuery. How do I get the path of the current URL and assign it to a variable?  Example URL:  http://localhost/menuname.de?foo=bar&amp;amp;number=0 Standard library sort and user defined types How to prove or disprove statements about sets Prove or disprove:  The set: $\{ \emptyset\}^{\Bbb N}$ has only one element.  The set $\emptyset^{\Bbb N}$ is empty.    I'm pretty sure both are true, for 1. all the natural numbers go to the empty set and that is the only element. Where as 2. all the natural numbers go to nothing so that's why it's empty. (Same as $ {\Bbb N}^{\emptyset} $ nothing goes to something is nothing (I think)). The problem is I have no idea how to show this so advice would be appreciated.  Edit: My defintion of a function is: $f:B\to A$ if  $(a_1,b),(a_2,b)\in f \ \Rightarrow \ a_1=a_2$ So for 2. I can simply say that: $(1,\emptyset),(2,\emptyset)\in f \Rightarrow a_1\neq a_2$  ? How do I change the default application for unknown file types? Ever since installing Bless Hex Editor, all unknown files and text files automatically open with Bless instead of gedit. How do I change it back? I don't want to have to manually associate files with gedit, I just want gedit to be the default if there's no other application set up to open the file.  Solution: modify ~/.local/share/applications/mimeapps.list  [Default Applications]  - text/plain=bless.desktop - application/octet-stream=bless.desktop + application/octet-stream=gedit.desktop Use Yaml for MongoMapper Config Why do we use "have" with does and not "has"? What is a tty, and how do I access a tty?