I'm creating a simple spellchecking program.  It basically loads in a dictionary and misspelled words.  I have a function aimed at removing repeats, and another function that generates all vowel combinations of a word to be checked. I'm having an issue with my vowel function.  I keep getting CurrentModifcationException, but I feel like it should be able to modify the array its adding words to as the array is statically defined at the top. Basically this function takes in an ArrayList and recursively adds additional words to the ArrayList which are vowel combinations of the word inputted. An example is if 'who' was inputted, it would add 'wha, whi, whe, whu' to the array list. The Code DEFINED AT TOP OF CONTAINER CLASS private static List&lt;String&gt; vowelList = new ArrayList&lt;&gt;(); private static ArrayList&lt;String&gt; checkList = new ArrayList&lt;&gt;();  private static void feedWordsForVowelCheck() {          for(String temp : checkList) {             System.out.println(&quot;Checking vowels for: &quot; + temp);           //  createVowelCombosStatic(temp, 0);             createVowelCombos(temp, 0 , checkList);         }         // System.out.println(&quot;Does this finish?&quot;);     }    private static void createVowelCombos(String word, int start, ArrayList&lt;String&gt; checkList) {         StringBuilder sbAddWord = new StringBuilder(word);         String[] splitWord = word.split(&quot;&quot;);                   if (start==splitWord.length) {             checkList.add(word);             return;         }                  if (splitWord[start].matches(&quot;.*[aeiou]&quot;)) {             for (int j = 0; j &lt; 5; j++) {                 sbAddWord.setCharAt(start, vowelList.get(j).charAt(0));                 createVowelCombos(sbAddWord.toString(),start+1, checkList);                 //System.out.println(sbAddWord.toString());             }         }         else             createVowelCombos(sbAddWord.toString(),start+1, checkList);     }
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.
When installing user applications, where do "best practices" suggest they be located? Occasionally I install applications manually, rather than using apt or another package manager.   What location (/usr/, /usr/local/, /opt/, /home/, etc.) is suggested by "best practices" for the installation of user applications? How to simplify the summation kk! without using induction? $$\sum_{k=1}^nk(k!)$$  I know the answer is (n+1)!-1..I can solve this question using principle of mathematical induction...but I would like to know if there is any other alternative approach Does the ANSI standard mandate the logical operators to be short-circuited, in either C or C++?  I'm confused for I recall the K&amp;R book saying your code shouldn't depend on these operations being short circuited, for they may not. Could someone please point out where in the standard it's said logic ops are always short-circuited? I'm mostly interested on C++, an answer also for C would be great.  I also remember reading (can't remember where) that evaluation order isn't strictly defined, so your code shouldn't depend or assume functions within an expression would be executed in a specific order: by the end of a statement all referenced functions will have been called, but the compiler has freedom in selecting the most efficient order.  Does the standard indicate the evaluation order of this expression?  if( functionA() &amp;&amp; functionB() &amp;&amp; functionC() ) cout&lt;&lt;"Hello world"; Euclidean Algorithm for GCD of polynomials I am struggling to use the Euclidean algorithm for polynomials.  Given something like $$GCD(x^5+1, x^3+1)$$  I can easily use it as follows:   $$x^5+1 = x^2(x^3+1) -x^2 +1 \\ x^3+1 = -x(-x^2+1) + x +1 \\ -x^2+1 = (x+1)(-x+1)$$  GCD = x+1  But for something like $$GCD(2x^2+6x+3, 2x+1)$$   I cannot figure out how to do it using the same method. I start like this:  $$2x^2+6x+3 = x(2x+1) + 5x+3\\ 2x+1 = \frac{2}{5}(5x+3) - \frac{1}{5}\\$$  and I am not sure how to continue. Any help would be appreciated, sorry for my poor attempt at using LaTeX. Extract substring in Bash How can I get around giving my mobile phone number to Google? When I want to register an account with Gmail now, it says "Google will send a text message containing a verification code to your mobile phone."  I don't want to give Google my mobile phone number!!  How do I get around this? Speed of light when accelerating I'm studying special relativity and saw the 2 postulates of Einstein. The most remarkable one for me is the universal speed of light. Einstein postulated that the speed of light in vacuum is the same for all inertial observers, regardless of the motion of the source. But what if we are accelerating and we are changing from one inertial frame to another, how will we observe the speed of light? Is it still the same? I suggest it's not? Because I alread saw a small introduction to general relativity where the light will bend in a gravitational field and therefore also when you accelerate. So does the speed of light change because it bends? Distinguishing whether "up" is a preposition or a part of a phrasal verb in this case In the sentences below, “bill” and “hill” are both nouns.    He ran up a big hill. He ran up a big bill.   Can someone explain how one distinguishes whether “up” is a preposition or a part of a phrasal verb? Confused about the possibility of different differentiable structures. In Loring Tu's "An Introduction to Manifolds" an atlas on a manifold is a collection of coordinate charts that are pairwise compatible and cover the manifold. A smooth manifold is defined to be a topological manifold together with a maximal atlas or differentiable structure. The maximal atlas is constructed by taking an atlas and appending all coordinate charts that are compatible with the atlas and using this he shows that any atlas on a locally Euclidean space is contained in a unique maximal atlas.  He also later shows that for any chart on a manifold, the coordinate map is a diffeomorphism onto it's image.   My question arises when Tu mentions in an aside that every compact topological manifold in dimension four or higher has a finite number of differentiable structures. What I don't understand is how it is possible for a smooth manifold to have more than one differentiable structure. Doesn't the fact that for any chart the coordinate map being a diffeomorphism coupled with the fact that composition of smooth functions is smooth mean that any two coordinate charts on a manifold are compatible and thus they must all belong to one maximal atlas? How is it possible to have another? Am I not understanding the word "maximal" or atlas or some other concept? Do newer laptop batteries still need to be drained before recharging? 10 years ago when I was doing hardware support it was best practice to fully drain a laptop battery prior to recharging in order to maximize its life.  Is this still the case or can a battery now be recharged at any point without worrying about shortening the lifespan? "Continuity" of stochastic integral wrt Brownian motion How can I center a too wide table? I have a document containing a table which is slightly too wide for the page. But instead of growing to the right side only, I would like to have it centered on the page.  I have tried to use the center environment but this doesn't seem to help. Precedence of user and group owner in file permissions I just ran into something unexpected (for me) regarding file permissions on Linux (Arch Linux). Basically I have:   userX in groupX fileX userX:groupX ---rwx----   What puzzles me: I cannot perform any action (rwx) on fileX. Is this right? Can someone please confirm this is indeed the expected behaviour?  The only actions I can perform are mv and rm because I have write permissions on the parent directory.  The thing is, I always thought these permissions collapse on each other, starting with the most general one (other -> group -> user). In other words, if o=rwx who cares what the persmissions for group and user are? Apparently this is not the case but it doesn't make much sense to me; it seems counterintuitive. The only thing this approach seems to be useful at, is to easily exclude a very specific person / group, which doesn't seem like a smart way to go at it (imho). Besides, the owner (and group?) should be able to chmod anyway right? Any thoughts on this matter? What is the difference between "I am done" and "I am through"? Advanced search criteria for bounty questions? All active questions with awarded bounty can be seen in the Featured tab. However, there seems to be way to make searches to the contents of any particular question tab.  I realize that this is pretty much a duplicate of  but it has no clear answer whether there are any plans of supporting bounty searching or not.  So, could there possibly be a hasbounty:1 advanced search criteria? How to prove that minimum of two exponential random variables is another exponential random variable? How can I prove that the minimum of two exponential random variables is another exponential random variable, i.e. Z = min(X,Y) Tool to manage and/or make available a list of my publications on the web? What are the dangers of accepting gifts from unknown accounts on Steam? A user named 'steamfairy1' gifted me a game on Steam. I don't know this user, their profile shows no games, no friends and zero hours played. The profile of 'steamfairy1' was created the day I received the gift.  It very much looks like a scam, but I can't figure out how the scam is supposed to work. What's the worst thing that could happen if I accept the gift? Any idea what the trick here is? It could be just a random act of kindness and I'm just paranoid…  I contacted the Steam support, but they were unhelpful as usual: responding in the wrong language and with a canned one-liner that didn't make a whole lot of sense or had much to do with my question.  Keywords (not really tags, but I want this to be searchable): steamfairy, steam fairy What IDE to use for Python? Approximating commuting matrices by commuting diagonalizable matrices Suppose the matrices $A$ and $B$ commute. Do there exists sequences $A_n$ and $B_n$ of matrices such that   $A_n \rightarrow A$, $B_n \rightarrow B$.  Each $A_n$ is diagonalizable  and the same for each $B_n$.  For every $n$, $A_n$ commutes with $B_n$.    Moreover, it would be nice if the following property was additionally satisfied: if $A,B$ are real, then $A_n,B_n$ can be chosen to be real as well.