Issues with detecting a string within a string On a site called Codingbat.com I have been presented with the challenge of detecting whether a string ends in "ly" or not. I have thoroughly checked my code, but it doesn't seem to be working. When I input "ly" it detects perfectly fine, however, words such as "oddly" or "exactly" don't issue the true Boolean response as they should. Here is my code so far:  if (str.length() &gt; 1) {   String lastTwo = str.substring(str.length()-2, str.length());   if (lastTwo == "ly") {     return true;   } else {     return false;   } } else {   return false; }
How do I compare strings in Java? 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?
Starting scheduled task by detecting connection of USB device Prove that $\int_0^\infty \frac{x\,\log x}{(1+x^2)^2} = 0$ I have been asked to prove that $$\int_0^\infty \frac{x\,\log x}{(1+x^2)^2}\,dx = 0$$  I tried proceeding as follows: \begin{align} \int_0^\infty \frac{x\,\log x}{(1+x^2)^2}\,dx &amp;= \int_0^1 \frac{x\,\log x}{(1+x^2)^2}\,dx + \int_1^\infty \frac{x\,\log x}{(1+x^2)^2}\,dx \\ &amp; = \int_0^1 \frac{x\,\log x}{(1+x^2)^2}\,dx + \int_{u=1}^0 \frac{u\,\log u}{(1+u^2)^2}\,du\quad (\text{where }u=1/x) \\ &amp;= \int_0^1 \frac{x\,\log x}{(1+x^2)^2}\,dx - \int_0^1 \frac{u\,\log u}{(1+u^2)^2}\,du \\ &amp;=^? \int_0^1 0 \,dx \\ &amp;= 0 \end{align}  But I think that I should first show that the improper integral $\int_0^1 {x\,\log x}/{(1+x^2)^2}\,dx$ is convergent.  Do I need to show it? If yes, how to do so?  (I have been taught basic methods such as comparison, limit comparison and Dirichlet test.) Android Debugging, how? User suggested great corrective edit to my answer, but the edit was rejected. What can I do to approve it? A nice user suggested  to . The edit, though very good and desirable, was rejected. I do not understand the reasons, and I did not find a way to contact those people who rejected it. What can I do to re-approve the edit? Standard deviation of binned observations I have a dataset of sample observations, stored as counts within range bins. e.g.:  min/max  count 40/44    1 45/49    2 50/54    3 55/59    4 70/74    1   Now, finding an estimate of the average from this is pretty straight forward.  Simply use the mean (or median) of each range bin as the observation and the count as a weight and find the weighted average:  $$\bar{x}^* = \frac{1}{\sum_{i=1}^N w_i} \sum_{i=1}^N w_ix_i$$  For my test case, this gives me 53.82.  My question now is, what's the correct method of finding the standard deviation (or variance)?  Through my searching, I've found several answers, but I'm unsure which, if any, is actually appropriate for my dataset.  I was able to find the following formula both  and .  $$s^{2*} = \frac{ \sum_{i=1}^N w_i (x_i - \bar{x}^*)^2 }{ \frac{(M-1)}{M} \sum_{i=1}^N w_i }$$  Which gives a standard deviation of 8.35 for my test case.  However, the Wikipedia article on  gives both the formula:  $$s^{2*} = \frac{ \sum_{i=1}^N w_i}{(\sum_{i=1}^N w_i)^2 - \sum_{i=1}^N w_i^2} \sum_{i=1}^N w_i(x_i-\bar{x}^*)^2$$  and  $$s^{2*} = \frac{1}{(\sum_{i=1}^N w_i) - 1} \sum_{i=1}^N w_i(x_i-\bar{x}^*)^2$$  Which give standard deviations of 8.66 and 7.83, respectively, for my test case.  Update  Thanks to @whuber who suggested looking into Sheppard's Corrections, and your helpful comments related to them.  Unfortunately, I'm having a difficult time understanding the resources I can find about it (and I can't find any good examples).  To recap though, I understand that the following is a biased estimate of variance:  $$s^{2*} = \frac{1}{\sum_{i=1}^N w_i} \sum_{i=1}^N w_i(x_i-\bar{x}^*)^2$$  I also understand that most standard corrections for the bias are for direct random samples of a normal distribution.  Therefore, I see two potential issues for me:   These are binned random samples (which, I'm pretty sure, is where Sheppard's Corrections come in.)  It's unknown whether or not the data is for a normal distribution (thus I'm assuming not, which, I'm pretty sure, invalidates Sheppard's Corrections.)   So, my updated question is; What's the appropriate method for handling the bias imposed by the "simple" weighted standard deviation/variance formula on a non-normal distribution? Most specifically with regards to binned data.  Note: I'm using the following terms:     $s^{2*}$ is the weighted variance   $N$ is the number of observations.  (i.e. the number of bins) $M$ is the number of nonzero weights.  (i.e. the number of bins with counts) $w_i$ are the weights  (i.e. the counts) $x_i$ are the observations.  (i.e. the bin means) $\bar{x}^*$ is the weighted mean. Why is "letter" not plural in "two letter words"? Why is "letter" not plural in "two letter words"?  For me it's very strange as the equivalent in French would be plural but my English friend finds it totally normal. How can one predict whether an individual infected with the SARS-CoV-2 virus will be asymptomatic? According to  , half of the   virus carriers show no symptoms.   What are the biological factors that determine whether an infected individual will be asymptomatic or not? How to remove "phone style" Gnome swipe to unlock MacBook Pro never goes to sleep I got a brand new mid-2015 MacBook Pro 15", OSX 10.11.3.  Display never turns off even it is configured to turn off after 10 mins in power adapter AND in battery mode. Screen saver (aerial) stays active forever. I tried disconnecting all USB peripherals connected - it did not help.  Any ideas? How to get a list of applications installed in Ubuntu dash? Handling of special LaTeX characters in text Greatest comeback in 2nd leg match References in externalized pgfplots I was writing on an document with a lot of pgfplots in it. Because of the memory limitation in LaTeX and in order to save some compiling time I tried out the externalize command. With most of the plots it perfectly worked out. But when I use the \ref command, namely \ref{&lt;legendname&gt;} the legend gets lost and instead there is a ??.  I think this question in a way is similar to  and . But no answer to these questions could solve my problem. Even the use of xr and zref packages showed no effect.  Am I just missing something?    MWE of the maindocument:  \documentclass{article} \usepackage{zref-user} \usepackage{xr-hyper} \usepackage{pgfplots} \usetikzlibrary{pgfplots.groupplots} \usepgfplotslibrary{external}  \tikzexternalize \externaldocument{part1}  \begin{document} \input{part1} \end{document}     With part1.tex looking like this:  \begin{tikzpicture}     \begin{groupplot}[       group style= {  columns=3,xlabels at=edge bottom,                 y descriptions at=edge left,                 horizontal sep=2cm,group name=plots},     width=0.4\textwidth,     xtick=data,     legend columns=3]     \nextgroupplot[xlabel=site 1,legend to name=grouplegend]     \addplot coordinates {(1,20)(2,23)(3,24.5)};     \addlegendentry {AaAaA,BbBbB,CcCcC}%     \nextgroupplot[xlabel=site 2]     \addplot coordinates {(1,14)(2,16)(3,17)};     \nextgroupplot[xlabel=site 3]     \addplot coordinates {(1,10)(2,11.5)(3,12.25)};     \end{groupplot}   % Legend     \node at (plots c2r1.north) [anchor=south] {\ref{grouplegend}}; \end{tikzpicture}     I'm writing with MikTeX 2.9 and the latest updates of the packages used. For compiling I used the command pdflatex -enable-write18 &lt;file name&gt;.  I hope the MWE is short enough ;) and some knows how to solve this problem. Find the value of:$$\frac{\sqrt{45} + \sqrt{18}} {\sqrt{7+2\sqrt{10}}}$$      I need help solving this question. Every reply is appreciated.  Thanks! How can I show that $ab \sim \gcd (a,b) {\operatorname{lcm} (a,b)}$ for any $a,b \in R \setminus \{0\}$? Let $R$ be a UFD. Then for any two elements $a,b \in R \setminus \{0\}$ $ab \sim \gcd (a,b){\operatorname{lcm} (a,b)}$.   My attempt :  Let $d = \gcd (a,b)$.Then $d|a$ and $d|b$.Then $\exists x,y \in R$ such that $a = dx$ and $b = dy$.Now it is to be shown that $c = dxy$ is the lcm of $a,b$.Which I find difficulty to show.It is clear that $a|c$ and $b|c$. Now if $u$ is any common multiple of $a$ and $b$.Then $dx|u$ and also since $y|b$ we have $y|u$ i.e. $dxy|u^2$ $\implies c|u^2$.But I have to show $c|u$ to complete the proof which I fail to prove.Please help me to complete the proof.  Thank you in advance. Running own executable on Android shell I need a specific command line tool and I have made a C program in my Linux shell. I have compiled the program with an ARM cross-compiler. I have then moved the program into the Android file system and tried to run it.  The output is permission denied.  What do I have to do, in order to run my own compiled programs in Android file system? How can I remap a keyboard key? Is CAT5 cable good enough for RS-485 vs "true" RS-485 cable How does one decide whether to use who or that? In the title example:   The correct pronoun is who. The correct pronoun is that. Either is correct. They're interchangeable. It depends on the context. How do I clone a generic list in C#?