The first method finds the duplicate and the second removes it.  I tried the following code and it does not work. I don't understand why. to be done using two methods. When I call the methods, they do not remove the duplicates. The arraylist is unchanged. I want to remove the duplicates using two methods.   public static int find(ArrayList&lt;String&gt; s, int i) {      for (int j = i + 1; j &lt; s.size(); j = j + 1) {         if (s.get(i) == s.get(j)) {             return j;         }     }      return -1; }   public static void removeDuplicates(ArrayList&lt;String&gt; s) {     for (int i = 0; i &lt; s.size(); i = i + 1) {         int foundAt = (find(s, i));         if (foundAt &gt;= 0) {             s.remove(i);         }     } }
I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.  Is == bad? When should it and should it not be used? What's the difference?
Is the Eel immortal? Cardinality of equivalence relations on N How can I disable the Windows 8 charms bar? Can someone please tell me how to disable the annoying effect that pops up when you drag cursor to top- or bottom-right corners? iOS 11-13 - unable to paste into comments If $z_{1},z_{2},z_{3}$ are three complex number Such that $|z_{1}| = 2\;\;,|z_{2}| = 3\;\;, |z_{3}| = 4\;\;$ Then $\max$ of $|z_{1}-z_{2}|^2+|z_{2}-z_{3}|^2+|z_{3}-z_{1}|^2$  $\bf{My\; Try::}$ Let $z_{1}=2\left(\cos \alpha+i\sin \alpha\right)$ and $z_{2}=3\left(\cos \beta+i\sin \beta\right)$ and $z_{3}=4\left(\cos \gamma+i\sin \gamma\right)$ So $$f(\alpha,\beta,\gamma) = 58-\left[12\cos(\alpha-\beta)+24\cos(\beta-\gamma)+16\cos(\gamma-\alpha)\right]$$ Now How can I calculate $\max$ of $f(\alpha,\beta,\gamma)$ Help me Thanks During Winterbash 2014, there was a hat called , which was earned by giving an answer scoring 5 or better to question that had a score of −3 or worse at the time of answering and later rose to a score of +3 or better.  I’ve already shared the . Those cases give me a great deal of confidence that this would be a challenging badge trigger that would produce good behavior with a minor tweak. Here are the Red Barons earned on other sites:    (Logan Maingi) Mathematics  (Mike Miller) Mathematics  (Hugo) English Language and Usage  (tchrist) English Language and Usage  (Mr. Shiny and New 安宇) English Language and Usage  (Darth Satan) Science Fiction and Fantasy  (DVK) Science Fiction and Fantasy  (rolfl) Code Review  (Heslacher and Hosch250) Code Review  (Edward) Code Review  (janos and Manny Meng) Code Review  (Mark Mayo, Rory Alsop and MeNoTalk) Travel      (DJClayworth) Christianity  (McMagister) Puzzling   Looking through the timelines, I’m convinced that the answerer’s votes should be excluded from the pre-answer question score calculation. Doing that would have reduced the number of Red Barons to 16 across the network. However, the cost of making a badge harder to obtain is worth the benefit of avoiding giving people an incentive to manipulate question scores¹.  To wrap up, the hat seemed to have encouraged a number of great answers and rescued some questions that would otherwise have been lost to time. My outstanding questions are:   Were there any problems on questions where people were attempting to earn the hat, but failed? (Or any other problems I didn’t observe.) If not, should we  or create a new badge? If we create a new badge, what should it be called?   I’m especially interested in feedback that counters my own bias in favor of this idea. If I’m missing any problems, I’d like to know about them now.    ¹ Several questions were downvoted, answered, edited (sometimes trivially)  and upvoted by the user who earned the hat. Build a basic Python iterator How would one create an iterative function (or iterator object) in python? What other languages have features and/or libraries similar to Perl's format? tikz arc with -latex arrow tip Why the arc does not fit over the circle if we use -latex arrow tip? Maybe some bug or some bad math computations?    MWE  \documentclass[11pt,margin=2pt]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta}  \begin{document} \begin{tikzpicture} \draw         (0:1cm) arc (0: 180:1cm) arc (180:0:1cm and 2cm); \draw         (0:1cm) arc (0:-180:1cm); \draw[-&gt;]     (0:1cm) arc (0:  80:1cm); \draw[-latex] (0:1cm) arc (0:- 80:1cm); \end{tikzpicture} \end{document} My users are sending me point data that were digitized using Google Earth. How can I convert their KML to a shapefile and vice versa? Free UML drawing library for .NET Row colour gaps in tabularx with \aboverulesep and \{} \documentclass[]{article} \usepackage[table,dvipsnames]{xcolor} \usepackage{multicol,booktabs,tabularx}  % Table settings \renewcommand{\aboverulesep}{1pt} \renewcommand{\belowrulesep}{1pt}  \begin{document}     \begin{tabularx}{\textwidth}{@{}X l@{}}         This is Header 1 &amp; This is Header 2 \\         \toprule         \rowcolor{Apricot}         This is Text 1 &amp; This is Text 2 \\\midrule         This is Text 1 &amp; This is Text 2 \\\midrule         This is Text 1 &amp; This is Text 2 \\         \bottomrule     \end{tabularx} \end{document}   I have the above table MWE using tabularx, and I am trying to colour the row from the table. However, due to the use of my \aboverulesep and \belowrulesep, I now have gaps above and below my table row that is not coloured.   Also, because of the use of my @{} on either side of the table to 'remove' the excess padding on the sides of the table, the row colour is being applied in those padding as well.   Qn 1: How can I colour the aforementioned gaps (arising due to the \aboverulesep) in, while maintaining the rule separation?   Qn 2: How to remove the colour from the two sides of the table?     EDIT  This is in response to Zarko's answer. I want to maintain the use of @{} on either side to remove the padding. If I were to adapt this into your answer, like so:  % @Zarko's answer \documentclass{article} \usepackage[table,dvipsnames]{xcolor} \usepackage{booktabs, cellspace, tabularx}  % Table settings \renewcommand{\aboverulesep}{0pt} \renewcommand{\belowrulesep}{0pt} \setlength\cellspacetoplimit{5pt} \setlength\cellspacebottomlimit{5pt}  \begin{document}     \begin{tabularx}{\textwidth}{@{}SX Sl@{}}% &lt;-- S is append for activate additional vertical space          This is Header 1 &amp; This is Header 2 \\         \toprule         \rowcolor{Apricot}         This is Text 1 &amp; This is Text 2 \\\midrule         This is Text 1 &amp; This is Text 2 \\\midrule         This is Text 1 &amp; This is Text 2 \\         \bottomrule     \end{tabularx} \end{document}   I obtain this:   and so my second question (Qn2) is still unresolved.. For Qn 1, I prefer to use the solution by @Skillmon with \renewcommand{\arraystretch}{1.15} as I need not add a new package. Sufficiency to prove the convergence of a sequence using even and odd terms Punctuation with units I remember reading somewhere that if a unit is abbreviated as one character, there must not be a space between the number and the unit (e.g., 5m, 26K). If the unit is abbreviated as two or more Characters, there must be a space between the number and the unit (e.g., "10 km", "USD 5").   Can you please help me find the source again? Is this recommendation correct? I added addresses of python 2.7, and Anaconda 4.1.1(Python 3.5) to PATH variable in Windows 10, whenever I run "python" from cmd, program which was added earlier is executed.How can I access both of them depending on my choice without altering name of either An exercise of Rudin's Real and Complex Analysis says:     Is it true that every compact subset of $\mathbf{R}^1$ is the support of a continuous function? If not, can you describe the class of all compact sets in $\mathbf{R}^1$ which are supports of continuous functions? Is your description valid in other topological spaces?   I proved that, in every metric space, a set (not necessarily compact) $A$ is the support of a continuous function if and only if it is the closure of an open set.  However, I don't think that this characterization holds for every topological space.  So, in order to find a counter-example, I tried to use the discrete and the trivial topologies. However, the discrete topology is metrizable and this characterization holds for topological spaces with the trivial topology.  Is this result true for any topological space? If not, what would be a counter-example? I have a Trek 3900 Mountain bike that had a serious creaking problem whenever I would pedal.  I found that the ring that holds the Shimano sealed bearing was really loose.  I tightened it up and it helped somewhat.  It loosened up again and I put loktite on the threads and really tightened it up but it is still creaking a little.  The bearing cartridge seems fine.  Any ideas? If $F: \mathbb R^2 \to \mathbb R$ and $F_x$ (partial derivative of $F$ wrt $x$) and $F_y$ exist at $(x_0,y_0)$ then the function is continuous at that point. Is this true? If not what could be a counter-example? How to create multiplied identity t-sql? How to convince airport security that I am not dangerous when having metallic parts in my body?