@Test public void testListCur(){     List&lt;String&gt; li=new ArrayList&lt;String&gt;();     for(int i=0;i&lt;10;i++){         li.add("str"+i);     }      for(String st:li){         if(st.equalsIgnoreCase("str3"))             li.remove("str3");     }     System.out.println(li); }   When I run this code,I will throw a ConcurrentModificationException.  It looks as though when I remove the specified element from the list, the list does not know its size have been changed.  I'm wondering if this is a common problem with collections and removing elements?
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.
Is fractional scaling ( ) available in 18.04 LTS yet? I am waiting until this is available before I install. I am a citizen of two different countries, and have two passports.  How should I use my passports when traveling? What exactly do the colors in htop status bars mean? Pigeonhole-principle with two choices I am able to solve this sort of problem pretty easily.     An arm wrestler is the champion for a period of 75 hours. The arm   wrestler had at least one match an hour, but no more than 125 total   matches. Show that there is a period of consecutive hours during which   the arm wrestler had exactly 24 matches.   However this homework problem I can't seem to figure out.     Tyler has five weeks to prepare for his driver’s test. His mother   volunteers to ride with him for either 15 minutes or one half hour   every day until the test but not for more than 15 hours in all. Show   that during some period of consecutive days, Tyler and his mother will   drive for exactly 8.75 hours.   If I try doing it the same way as the first problem. I get $70$ pigeons and $95$ pigeon holes. I honestly don't know where to start with this problem. I thought that maybe I could assume that they only drove $.25$ hours on each day and prove that there is a period of consecutive days where they drove for exactly $8.75$ hours. Then I could say that we assume there is one day that they drove for $.5$ hours and work my way up, but I can't seem to get that to work either. How to get the center line between two linestrings Where is the track of a ship when it is shipping always in the center of the   between the coasts of Great Britain and France?   I started with 2 linestrings and I created a lot of points on the linestring with a . After that I created a distance matrix with Raster/Analysis/Proximity in QGIS. Finally I created an aspect raster from the output raster.     Is the red line really the "center line" between these two linestrings?  Is there a more efficient way to do this? Since I can't find any alternative to Linux'  elevation command, I have the following question:  How to define a PowerShell function which requires elevation? I mean UAC prompt.  Say, such function follows:  function system-check {     SFC /ScanNow }   System:  Windows 8.1 Pro 64-bit  PowerShell:   Major  Minor  Build  Revision -----  -----  -----  -------- 5      0      10586  117    EDIT1:  To be 100% understandable let me rephrase:   I run PowerShell as user I run the aforementioned function system-check I want the function to elevate in order to be able to execute the command; note, that I want the UAC prompt to appear REST Service API executor.executeAsync Call Ends in Failure Function in Sharepoint Hosted App Any Answers Will Help me to Forward and Gain Knowledge in SharePoint Development  While i am Trying to get the list Items Using Rest API Calls in SharePoint Hosted App Using Below Function  function loadingSamples()  {     var JobListName = "RRR Jobs #";     var executor;     // Initialize the RequestExecutor with the app web URL.     executor = new SP.RequestExecutor("/");      //Fetching the choice values from the Job Status Field, to show in the Dropdown field     executor.executeAsync     ({         url: "/_api/web/lists/getbytitle('" + encodeURIComponent(JobListName) + "')/fields/getbytitle('Job Status')?$select=Choices",         method: "GET",         headers: { "Accept": "application/json; odata=verbose" },         success: successHandlerStatus,         error: errorHandler     }); } function successHandlerStatus(data)  {     alert("sucesss") }  function errorHandler(data, errorCode, errorMessage)  {     alert("errorMessage") }   It's always going to error function named errorHandler With  Error Code as -1002 and Error Message as Bad Request and Inside Data -> Body , the Error message is  {     "error":{            "code":"-1,Microsoft.SharePoint.Client.InvalidClientQueryException",         "message":{             "lang":"en-US",             "value":"The expression \"web/lists/getbytitle('DWR Jobs \" is not valid."         }     } }   Note :    This is working code in Sharepoint Hosted App that previously hosted in another Windows server. Now i hosted this App in New windows server,it's successfully hosted but it gives above mentioned Error in Rest Service Call. I had this question:    All 3 responses were rated at 1 when the bounty expired. Nothing got selected as the "best answer", and I can't even manually select an answer. Why does my dock keep moving back to my other monitor? I have a larger, external monitor connected to my MacBook Pro and have arranged it such that the dock is in the external monitor (via System Preferences > Displays > Arrangement, by dragging the white bar to the larger screen). This works fine, except for the fact that every now and then, the dock will suddenly shift back to my MacBook screen, but when I open up Displays to change this back, the white bar is still on the external monitor. So I have to drag it to the smaller screen, and then drag it back to the external monitor.   It's a minor issue, obviously, but I've noticed that it has been happening more and more frequently and it's getting quite annoying. Perhaps there's something I've been doing unintentionally for this to happen?   I'm using Mavericks, 10.9.5. Why does everyone's wand still work for them? How to rename multiple files sequentially from command line? How to rename file as below  AS1100801000002.RAW7AGS  AS1100801001008.RAW7AH4 AS1100801002001.RAW7AH9 AS1100801003002.RAW7AHE AS1100801004009.RAW7AHT AS1100801005002.RAW7AHY AS1100801010002.RAW7AJ3   to new name  AS1.txt AS2.txt AS3.txt AS4.txt AS5.txt AS6.txt AS7.txt Assume $\bar A\cap\bar B=\emptyset$. Is $\partial (A \cup B)=\partial A\cup\partial B$, where $\partial A$ and $\bar A$ mean the boundary set and closure of set $A$?   I can prove that $\partial (A \cup B)\subset \partial A\cup\partial B$ but for proving $\partial A\cup\partial B\subset \partial (A \cup B)$ it seems not trivial. I tried to show that for $x\in \partial A\cup\partial B$ WLOG, $x\in \partial A$ so $B(x)\cap A$ and $B(x)\cap A^c$ not equal to $\emptyset$ but it seems not enough to show the result. Why are some of my screen-recording/capturing/sharing applications (or app features) not working in Ubuntu 17.10 (and later releases)? How to enable ssh root access on Ubuntu 14.04 I´d like to enable the ssh root access on Ubuntu 14.04. Editing the /etc/ssh_config (PermitRootLogin yes) didn't affect anything. $p_1p_2...p_n +1$ is not square for $p_k = k$'th prime Normal subgroup of prime order is characteristic I'm stuck on this exercise from Herstein's topics in algebra:  Suppose that $G$ is a group and $|G| = pm$, where $p \nmid ~ m$ and $p$ is a prime. If $H$ is a normal subgroup of order $p$ in $G$, prove that $H$ is characteristic.  How to prove that? What we know:   $H$ and $\varphi(H)$ have prime order $p$, so they must be cyclic and abelian They are both normal subgroups of $G$   how to show that, in fact, we have $H = \varphi(H)$ for every automorphism $\varphi$ ? Although elements like &lt;div&gt;s normally grow to fit their contents, using the float property can cause a startling problem for CSS newbies: If floated elements have non-floated parent elements, the parent will collapse. For example:   &lt;div&gt;   &lt;div style="float: left;"&gt;Div 1&lt;/div&gt;   &lt;div style="float: left;"&gt;Div 2&lt;/div&gt; &lt;/div&gt;    The parent div in this example will not expand to contain its floated children - it will appear to have height: 0. How do you solve this problem? I would like to create an exhaustive list of solutions here. If you're aware of cross-browser compatibility issues, please point them out. Solution 1 Float the parent.   &lt;div style="float: left;"&gt;   &lt;div style="float: left;"&gt;Div 1&lt;/div&gt;   &lt;div style="float: left;"&gt;Div 2&lt;/div&gt; &lt;/div&gt;    Pros: Semantic code. Cons: You may not always want the parent floated. Even if you do, do you float the parents' parent, and so on? Must you float every ancestor element? Solution 2 Give the parent an explicit height.   &lt;div style="height: 300px;"&gt;   &lt;div style="float: left;"&gt;Div 1&lt;/div&gt;   &lt;div style="float: left;"&gt;Div 2&lt;/div&gt; &lt;/div&gt;    Pros: Semantic code. Cons: Not flexible - if the content changes or the browser is resized, the layout will break. Solution 3 Append a &quot;spacer&quot; element inside the parent element, like this:   &lt;div&gt;   &lt;div style="float: left;"&gt;Div 1&lt;/div&gt;   &lt;div style="float: left;"&gt;Div 2&lt;/div&gt;   &lt;div class="spacer" style="clear: both;"&gt;&lt;/div&gt; &lt;/div&gt;    Pros: Straightforward to code. Cons: Not semantic; the spacer div exists only as a layout hack. Solution 4 Set parent to overflow: auto.   &lt;div style="overflow: auto;"&gt;   &lt;div style="float: left;"&gt;Div 1&lt;/div&gt;   &lt;div style="float: left;"&gt;Div 2&lt;/div&gt; &lt;/div&gt;    Pros: Doesn't require extra div. Cons: Seems like a hack - that's not the overflow property's stated purpose. Comments? Other suggestions? I know from reading about the gravitational waves detected by Ligo, that when an object has angular acceleration, it produces gravitational waves.  I'm wondering if an object creates gravitational waves when only accelerating in one direction, however?   I'm also curious as to how the nature of the waves would differ in this case. What conservation law corresponds to Lorentz boosts? Noether's Theorem is used to relate the invariance of the action under certain continuous transformations to conserved currents. A common example is that translations in spacetime correspond to the conservation of four-momentum.  In the case of angular momentum, the tensor (in special relativity) has 3 independent components for the classical angular momentum, but 3 more independent components that, as far as I know, represent Lorentz boosts. So, what conservation law corresponds to invariance under Lorentz boosts? I've checked in the home folder but this is all I see.