For an assignment, I have to create a method that takes in an ArrayList and removes repeated elements from it (case insensitive). Additionally, it needs to change the case of the element to match that of the last occurrence of that String in the ArrayList.   Right now I'm trying a 3-step process: creating a new ArrayList of Strings and filling it with elements identical to those of the input one. Then I use nested for-loops to iterate through it, change repeats of elements to "REMOVE_THIS_STRING", and change the first instance of each String to match the capitalization of the last instance. Then afterwards, in another loop, I go through and remove all elements that match the "REMOVE_THIS_STRING" String. I know that this isn't the most efficient way to go about things, but I haven't worked much with other types of collections so I'm hesitant to mess with those right now and would prefer an approach that only uses ArrayLists, if possible.   /* Code that creates the NewArrayList ArrayList and fills it  with elements identical to that of the input ArrayList */    for(int i=0; i&lt;input.size(); ++i) {    String currentWord = input.get(i);    for(int j=i+1; j&lt;input.size(); ++j) {       String wordToCompare = input.get(j);        if(currentWord.equalsIgnoreCase(wordToCompare)) {          currentWord = wordToCompare;          newArrayList.set(i, wordToCompare);          newArrayList.set(j, "REMOVE_THIS_STRING");       }    } }    /* Code that goes through NewArrayList and removes  all Strings set to "REMOVE_THIS_STRING" */   If the ArrayList input is "interface", "list", "Primitive", "class", "primitive", "List", "Interface", "lIst", "Primitive", the expected output is "Interface", "lIst", "Primitive", "class", but instead I'm getting "Interface", "lIst", "Primitive", "class", "Primitive", "lIst"
I have an ArrayList&lt;String&gt;, and I want to remove repeated strings from it. How can I do this?
Countability of disjoint intervals According this problem/solution set from an MIT class (http://ocw.mit.edu/courses/mathematics/18-100c-analysis-i-spring-2006/exams/exam1_sol.pdf), the assertion:  "Every collection of disjoint intervals in R is countable."  is True, because "every interval contains a rational number", and the rationals are countable.  It seems to me this should be False, with possible counterexample:  { [x,x] | x is an element of R}  ie the set of all singelton intervals on R. Why isn't this a valid counterexample? Theorem 3.2 Rudin -- How is 0 concluded? I'm having trouble understanding why the arbitrariness of $\epsilon$ allows us to conclude that $d(p,p')&lt;0$. It seems we could likely conclude a value such as $\frac {\epsilon}{100}$ couldn't we?? The other idea that would normally work is the limit (as $n$ approaches $\infty$, $p$ approaches $p'$) but that would mean we are further in another sequence which would have same problem Thanks in advance   $\ $  $\ $  $\ $   Definition of Convergence     A sequence $\{ p_n \}$ in a metric space $X$ is said to converge if there us a point $p \in X$ with the following property: For every $ \epsilon&gt;0$ there is an integer $N$ such that $n \ge N$ implies distance function $d(p_n, p) &lt; \epsilon.$ How to make sense out of the $\epsilon-\delta$ definition of a limit? The informal intuition for the limit of a function is this:     What is the value of the function $f$ as $x$ gets infinitely close to $c$?   How on earth does this monster  $$ \lim_{x \to c} f(x) = L  \iff  (\forall \varepsilon &gt; 0)(\exists \ \delta &gt; 0) (\forall x \in D)(0 &lt; |x - c | &lt; \delta \ \Rightarrow \ |f(x) - L| &lt; \varepsilon)$$ capture our intuition?  I want the answer to explain and motivate every bit of this formal statement. Remember: I am able to parse the statement, I just don't see how it captures our informal intuition. pure code formatting, to enhance a question, is impossible (without 2k rep) Suppose $X_n$ is the fortune of a gambler after $n$ th game. Then the game is called fair (Breiman 1968) if   $$E[X_{n+1} \mid X_1, \dots, X_n] = X_n \forall n$$  My question is why a fair game is not defined as the following   $$E[X_{n+1}] = E[X_n] \forall n$$ i.e. $$E[X_{n+1}- X_n]=0$$. This should be the proper definition as a fair game is where avg. gain is zero. Nothing conditioning should be there. How to gather full network usage statistics on a freebsd router? I have a freebsd box, which serves as a router from LAN to the outside world. It has several Internet providers, OpenVPN servers and clients, NAT and so on.  I would like to have complete statistics on when, who, to whom, via which provider, via which protocol, and how many bytes have been sent.   I agree that the minimal time scale will be an hour, i.e. no need for millisecond precision.  I tried vnstat2, ntopng and some other programs, but they don't seemed to have what I need or it is not obvious.   I don't understand, why this feature is not easily available. But I am not good in freebsd, so please, give me some clues. could you help me on this integral ? $$\int \frac{1}{\cos(x)}\,\mathrm dx$$ Here's what I've started : $$\int \frac{1}{\cos(x)}\,\mathrm dx = \int \frac{\cos(x)}{\cos(x)^2}\,\mathrm dx = \int \frac{\cos(x)}{1-\sin(x)^2}\,\mathrm dx$$ Now, I did : $u = \sin(x)$, so $\mathrm du = 1$. Now I have : $$\int \frac{\text{???}}{1-u^2}\,\mathrm du$$ But at this point, I think I did the most of the job but I'm stuck. Could you help me to solve this integral please (to the integration by substitution at the end) ? Thanks EDIT : Now I follow the steps and I got : $$\int \frac{1}{1-u^2}\,\mathrm du$$ Doing the partial fraction I got $A = 1/2$ and $B = 1/2$. So basically I have : \begin{align} &amp; \int \frac{1}{1-u^2}\,\mathrm du = \int \frac{1/2}{1+u}\,\mathrm du + \int \frac{1/2}{1-u}\,\mathrm du \\[8pt] = {} &amp; \frac 1 2 \left(\int \frac{1}{1+u} \, du - \int \frac{1}{1-u} \, du\right) \\[8pt] = {} &amp; \frac 1 2 \ln\left(\frac{1+u}{1-u}\right) = \ln\left(\left(\frac{1+\sin(x)}{1-\sin(x)}\right)^{1/2}\right) \\[8pt] = {} &amp; \ln \left(\frac{\sqrt{1+\sin(x)}}{\sqrt{1-\sin(x)}}\right) = \ln\left(\frac{\sqrt{1+\sin(x)}}{\sqrt{\cos(x)^2}}\right) \\[8pt] = {} &amp; \ln\left(\frac{\sqrt{1+\sin(x)}}{\cos(x)}\right) \end{align} Here's what my teacher got :  What's wrong with what I did ? Did I miss something ? Performing deep learning land cover classification using R? I am really new to Deep Learning and, unfortunately, I can't find example codes on land cover classification other than  where the author wrote a script in R for a large dataset.   The main reason that I am asking is because recently I found a few papers on Remote Sensing Image classification using Deep Learning and I was wondering if there were any R examples on that subject.  So, is there a code example, preferably a step-by-step, which I can use?  I found several git repos like  that can do Deep Learning classification with R, BUTT, I am still looking for a simple multi-spectral image segmentation method. An example of that can be found at  and I also found a similar question in  for which the answer is "use something else other than R if you can".  If I find anything that works today I will be posting a working answer. Binary search (bisection) in Python PHP function to build query string from array I'm looking for the name of the PHP function to build a query string from an array of key value pairs. Please note, I am looking for the built in PHP function to do this, not a homebrew one (that's all a google search seems to return). There is one, I just can't remember its name or find it on php.net. IIRC its name isn't that intuitive. Can I safely use my camera with a external power supply? How to revert to GNOME Classic Desktop? I'm used to GNOME Classic and personally don't want to change to anything else, but it seems there is no more GNOME Classic in the Oneiric release. After apt-get installed gnome-session and all, though there comes back the GNOME Classic option in the session listbox, however, after logged in, it seems not the expected one.  There is no System menu in the top bar, and I couldn't customize panels at all. I want to change the appearance(theme), but I can't find Appearance menu at all. And much more differences to my previous experience of GNOME classic shell.    There are multiple valid answers for this question spanning over several versions of Ubuntu. For your convenience an index of each below:    and up      &amp; I noticed that the locked message still references the FAQ. See :  locked by  yesterday This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: .  Since the FAQ has been replaced by the , this message should provide a link there instead. Currently, the link actually takes you to the ; even if it doesn't link to the help center, the text should probably be something like &quot;More info: &quot;. I've been playing Agar for some time now, and lately I've noticed there was a new XP system in Agar. Since then I've been wondering what variables chance the XP gained. I've tried googling it, but with no luck.  I'm looking for how the XP system works in these game modes:   FFA Teams Experimental Maya is sister of dhara who is doctor. Maya is sister of dhara, who is doctor.   In both statements who is used for which person??? I'm confused, does the absorption and emission determine the color of something? Or does that only happen when something is emitting energy?  When light hits an object, the photons get absorbed, then emitted with a different wavelength right? I am not a administrator and I would like to find the administrator password. I would not like to reset it however. Is there anyway to find and not reset the administrator password? What constitutes protons? When I see pictures, I can't understand. Protons are made of quarks, but some say that they are made of 99% empty space. Also, in this illustration from Wikipedia, what's between the quarks? Login to Stack Exchange account doesn't use HTTPS/SSL? In C#, why can't a List object be stored in a List variable It seems that a List object cannot be stored in a List variable in C#, and can't even be explicitly cast that way.  List&lt;string&gt; sl = new List&lt;string&gt;(); List&lt;object&gt; ol; ol = sl;   results in Cannot implicitly convert type System.Collections.Generic.List&lt;string&gt; to System.Collections.Generic.List&lt;object&gt;  And then...  List&lt;string&gt; sl = new List&lt;string&gt;(); List&lt;object&gt; ol; ol = (List&lt;object&gt;)sl;   results in Cannot convert type System.Collections.Generic.List&lt;string&gt; to System.Collections.Generic.List&lt;object&gt;  Of course, you can do it by pulling everything out of the string list and putting it back in one at a time, but it is a rather convoluted solution.