In Java, is it legal to call remove on a collection when iterating through the collection using a foreach loop?  For instance:  List&lt;String&gt; names = .... for (String name : names) {    // Do something    names.remove(name). }   As an addendum, is it legal to remove items that have not been iterated over yet? For instance,   //Assume that the names list as duplicate entries List&lt;String&gt; names = .... for (String name : names) {     // Do something     while (names.remove(name)); }
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.
Consider the Fibonacci numbers $F(0) = 0; F(1)=1; F(n) = F(n-1) + F(n-2)$.  Prove by induction that for all $n&gt;0$,  $$F(n-1)\cdot F(n+1)- F(n)^2 = (-1)^n$$  I assume $P(n)$ is true and try to show $P(n+1)$ is true, but I got stuck with the algebra. How do we reach $P(n+1)$ from $P(n)$? Also, strong induction may be used instead. What is an example of Gâteaux differentiable but not Fréchet differentiable at a point in a finite-dimensional space? Let $V,W$ be nonzero normed spaces over $\mathbb{K}$ such that $V$ is finite-dimensional.  Let $E$ open in $\mathbb{K}$ and $p\in E$.  Let $f:E\rightarrow W$ be Gâteaux-differentiable at $p$.  Is $f$ necessarily Fréchet-differentiable at $p$ in this case?  I think this is not true in general, but cannot find a counterexample. What would be a counterexample? Prove if $n \in \mathbb N$, then $\frac{1}{2!}+\frac{2}{3!}+\frac{3}{4!}+\cdots+\frac{n}{\left(n+1\right)!} = 1-\frac{1}{\left(n+1\right)!}$   So I proved the base case where $n=1$ and got $\frac{1}{2}$  Then since $n=k$ implies $n=k+1$ I setup the problem like so:  $\frac{k}{(k+1)!}+\frac{(k+1)}{(k+2)!}=1-\frac{1}{(k+2)!}$  After trying to simplify it I got the following:  $\frac{k(k+2)!+(k+1)(k+1)!}{(k+1)!(k+2)!}=1-\frac{1}{(k+2)!}$  However, I'm having trouble simplifying it to match the RHS.  Hints? How do I "parent" objects? With the enthusiastic question of "Who wants ice-cream?", what is the more correct response?         (Not) I.   (Not) me.      Neither response is a sentence. The first response of "(not) I" sounds stuffy, like it should be followed with an indignant sniff. The second sounds like American idiom and acceptable for casual speech.    What do you say? Exec format error of gcc-compiled Hello World c++ On AWS Ubuntu Server, I wrote C++ Hello, World program:  #include &lt;iostream&gt; using namespace std;  int main(){         cout&lt;&lt;"Hello, World!"&lt;&lt;endl;         return 0; }   And compiled it:  ubuntu@ip-xxxxx:~/dev/c++$ g++ -c ./test.cc -o out ubuntu@ip-xxxxx:~/dev/c++$ chmod a+x out ubuntu@ip-xxxxx:~/dev/c++$ ./out -bash: ./out: cannot execute binary file: Exec format error ubuntu@ip-xxxxx:~/dev/c++$ file ./out ./out: ELF 64-bit LSB  relocatable, x86-64, version 1 (SYSV), not stripped ubuntu@ip-xxxxx:~/dev/c++$ uname -a Linux ip-xxxxx 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux ubuntu@ip-xxxxx:~/dev/c++$ gcc --version gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4   It seems that architecture x86-64 is the same each other. What is the problem here? Do I have to add more C++ flags? resizable serial console window? When using the serial console of my system I always end up with $COLUMNS=80 and $LINES=24.  While I can change these variables manually it is somewhat annoying to do this any time when the client side terminal window has been resized.  Usually I'm connecting to the console using screen /dev/mytty baudrate.  Changing the $TERM environment variable to "screen" or "xterm" does not help.  Will I need to call getty with some of those instead of vt100?  Needless to say that all of this works fine, when I connect to the same machine using ssh. Finding package name of installed software Since I have not been able to open Dash Home in 12.04.4 see , I am hoping for a work-around. Is there another convenient way to open apps/programs without having to search through folders? Is this question clear enough? For example, I just installed Kile (publishing program) from the Software Center, but I can't find a link/tile/icon/shortcut to open it. Thanks, to whomever can help. Proving the Lorentz invariance of the Lorentz invariant phase space element I have been looking around for a satisfactory answer to prove that  $$\frac{d^3\vec{p}}{2E_{\vec{p}}}$$  where $E_{\vec{p}}=+\sqrt{(|\vec{p}|c)^2+(mc^2)^2}$, is Lorentz invariant. The standard answer seems to be that the above measure is equal to  $$d^4p \, \delta (p^2-m^2)\theta(p_0)$$  where $p^2=p_0^2-|\vec{p}|^2$, and $\theta(x)$ is the step function. I understand these two are equivalent, but I don't understand why the second has to be Lorentz invariant, in particular why the Dirac delta has to be Lorentz invariant. I have found a  (section 2.1) that proves that $\delta^{(4)}(p-p')$ is Lorentz invariant, but I can't find a way to extend their method successfully here. In fact, all I can seem to get tells me the above isn't Lorentz invariant, and that in fact it should transform to   $$\frac{d^3\vec{p}'}{2\gamma E_{\vec{p}'}}$$  which makes sense from $d^4p$ being Lorentz invaraint and $dp_0$ transforming proportional to $\gamma$, but it isn't what everyone else says. What's the problem here?    An alternative way to "derive" the factor of $1/\gamma$:  $$\delta (p^2-m^2)\theta(p_0)=\frac{1}{E_{\vec p}}\delta(p_0-E_{\vec{p}})$$  Now, as $dp_0$ transforms to $\gamma dp_0$, the $\delta(p_0-E_{\vec{p}})$ should transform to $\gamma^{-1}\delta(p_0-E_{\vec{p}})$, as can be shown with an analogous argument to the one shown in the . The $E_{\vec{p}}$ also transforms to $\gamma(E_{\vec{p}}-v p_x)$ for an $x$-boost, but this doesn't seem to solve it. From Stewart 7e pg 614 # 9  "One model for the spread of a rumor is that the rate of spread is proportional to the product of the fraction y of the population who have heard th eremor and the fraction who have not hear the rumor. a) Write a differential equation that is satisfied by y. b) Solve the differential equation c) A small town has 1000 inhabitants. At 8 am 80 people have heard a rumor. By noon half the town has heard it. At what will 90 percent of the population have heard the rumor? "  The wording of this is very ambiguous to me and I can't really make sense of it.  They mention a product, so I know that something is being multiplied and that y is a fraction which belongs to the population who have seen it so I think that "have not" heard is a constant, and that y is a fraction taht represents who have. I tried to set this up and it is the wrong answer. I am not sure what they want from that, the English usage is too ambiguous to make sense of it. The complete lack of punctuation is what really does it. RF Energy Harvesting Why can energy invested in RF radiation not be harvested fully? What are the main factors that affect this? Is there any significant research nowadays that fully describes this process? I stand on the conclusion: "Energy moves from one form to another.", but in this case why can it not be harvested in that quantity to use it for powering low-power devices or store it in significant quantities in some batteries for later use? Why is it not profitable nowadays and why is it not used today like energy from water, wind and other energy sources? Calculate time elapsed in php - spans over 24 hours Bash Script if condition is always true How to overlay images When I gain control of a creature, do I also gain control of any auras or equipment attached to it? Find all solutions to the equation $(z+1)^6=z^6$. Express the solutions in simplified rectangular form. Hint: Clearly $z=0$ is not a solution. $$(z+1)^6=z^6 $$ $$\frac{(z+1)^6}{z^6 }=1$$ $$\left(\frac{(z+1)}{z }\right)^6=1$$ $$\left(\frac{(z+1)}{z }\right)^6=\cos(2*\pi*k)+i\sin(2*\pi*k)$$ $$\frac{(z+1)}{z }=\left(\cos(2*\pi*k)+i\sin(2*\pi*k)\right)^{1\over6}$$ $$1+\frac{1}{z }=\cos({2*\pi*k\over6})+i\sin({2*\pi*k\over6})$$  $$\frac{1}{z }=(\cos({\pi*k\over3})-1)+i\sin({\pi*k\over3})$$ $$\frac{1}{(\cos({\pi*k\over3})-1)+i\sin({\pi*k\over3}) }=z$$ I dont know how else to solve this. A lot of help is appreciated. Also i know that k should go from 1-5. Following a global preference for , as of now, the preferences for enabling keyboard shortcuts and disabling the fixed topbar are network-wide* as well.  If you had either checked off on any site in the network, that setting has been preserved and applied to the whole network for your account already. Future changes will also apply to all* Q&amp;A sites.  Find them in their usual spot as previously on the  pages.    * With the exception of , which will support the fixed topbar after the . Changing colors of lightning-button How can I change the colors of lightning-button?  I tried doing this in my css:  .my-button {     background-color: #14a6bc;     color: #ffffff; }   and applying that class to my &lt;lightning-button&gt; and removing the variant but I still get the base colors? I am trying to use these examples: If the electric field is the gradient of the potential, then can we say that whenever potential is zero, the electric field is zero? For example, in a dipole, at the center of the two charges making up the dipole, the potential is zero but the electric field is non-zero. But if $E = -\operatorname{grad}V$, then why is $E$ not zero?  Another example: In the case of two positive charges, the electric field is zero at the mid-point of line joining them, but potential is non-zero. What am I misunderstanding here? Is it because Rey just saved BB-8 from a net, and then the droid just decides to follow her about - or is it for some other reason?  Does BB-8 have any idea who Rey is prior to being rescued by her?  Just wondering as she literally tells the droid to go elsewhere.