I'm really sorry that I can't word my question properly. So I want to create an if-else scenario where you take string input from user and to print &quot;Oh, so your name is xyz&quot; if the input is correct, and to print &quot;Oh, so your name is not xyz&quot; if the input is wrong. String name = &quot;xyz&quot;; String lol = input.nextLine();             if (lol == name) {                 System.out.println(&quot;Oh, so your name is xyz&quot;);             } else {                 System.out.println(&quot;Oh, so your name is not xyz&quot;);             }             input.nextLine();             input.close();     }  But after I run the file I got something like this instead: What's your name? xyz Oh, so your name is not xyz  I've changed the if (lol == name) to if (lol != name) but it prints &quot;Oh, so your name is xyz&quot; even though the input is false. What's your name? asd Oh, so your name is xyz  This is the whole code: import java.util.Scanner;  public class MyClass {     static void myMethod() {                  Scanner input = new Scanner(System.in);                  System.out.println(&quot;Hello World&quot;);         System.out.println(&quot;What's your name?&quot;);                  String name = &quot;xyz&quot;;         String lol = input.nextLine();             if (lol == name) {                 System.out.println(&quot;Oh, so your name is xyz&quot;);             } else {                 System.out.println(&quot;Oh, so your name is not xyz&quot;);             }             input.nextLine();             input.close();     }          public static void main(String[] args) {         myMethod();     }  }  Thanks in advance.
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?
Which is the correct sentence?   The young cow is calf. The young cow is called calf. The young cow called as calf. I have a matrix which is kind of symmetrical with the other diagonal, i.e., something like  $$A = \left[ \begin{array}{c c c c}    a &amp; b &amp; c &amp; d \\    e &amp; f &amp; g &amp; c \\    h &amp; i &amp; f &amp; b \\    j &amp; h &amp; e &amp; a  \end{array} \right]$$  Does this matrix have a special name in literature? What are it's properties?  And a matrix that is symmetrical by both diagonals   $$A = \left[ \begin{array}{c c c c}    a &amp; b &amp; c &amp; d \\    b &amp; e &amp; f &amp; c \\    c &amp; f &amp; e &amp; b \\    d &amp; c &amp; b &amp; a  \end{array} \right]$$  What's the name of it? Any interesting properties? High Voltage Powerlines - clarification of energy loss Let's say that a player uses the ready action and says "If a character aims at me with a weapon, I'll use Teleport to move behind cover."  What happens? Does this work? If not, please cite the rules to explain why not. Let $s_n$ be a sequence defined as given below for $n \geq 1$. Then find out $\lim\limits_{n \to \infty} s_n$.   \begin{align}   s_n = \int\limits_0^1 \frac{nx^{n-1}}{1+x} dx  \end{align}  I have written a solution of my own, but I would like to know it is completely correct, and also I would like if people post more alternative solutions. Frequency dependence of electromagnetic reflection I was surprised to see that the Fresnel equations for reflection depends on refractive index and angle of incidence, but they do not depend on frequency. Why is this case? Are they restricted to regions that do not show frequency dependence? How to open a web page from my application? I want to make my WPF application open the default browser and go to a certain web page.  How do I do that? Quick-and-dirty way to ensure only one instance of a shell script is running at a time What's a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time? Will I lose previous purchases when I change country in iTunes Create a virtual file that is actually a command Is there any way to create a virtual file, such that reading from the file actually reads from the stdout of a command; writing to the file is acually writing to the stdin of a command?  So far I have kludged this with an inotifywait on a file, which calls a command when the file is modified, taking it's input from the file and writing back to it.  I don't like that the inotifywait has to be constantly restarted though (and I have to ensure that it is always running). I only use this file perhaps twice a week. I have a method that I would like to call.  However, I'm looking for a clean, simple way to kill it or force it to return if it is taking too long to execute.  I'm using Java.  to illustrate:  logger.info("sequentially executing all batches..."); for (TestExecutor executor : builder.getExecutors()) { logger.info("executing batch..."); executor.execute(); }   I figure the TestExecutor class should implement Callable and continue in that direction.  But all i want to be able to do is stop executor.execute() if it's taking too long.  Suggestions...?  EDIT  Many of the suggestions received assume that the method being executed that takes a long time contains some kind of loop and that a variable could periodically be checked. However, this is not the case.  So something that won't necessarily be clean and that will just stop the execution whereever it is is acceptable. How to prove  $$\int_{0}^{\infty} \mathrm{e}^{-x^2}\, dx = \frac{\sqrt \pi}{2}$$ One time pad: why is it useless in practice? The symmetric cryptosystem one-time pad (OTP) seems to be very beautiful since it is perfectly secret according to Shannon. Many books, however, point out the main drawback: one must create a secret key the same length as the plaintext. For this reason, the concept of perfect secrecy has these days been abandoned, and we prefer other cryptosystems.   Now, for example, suppose I want to encode my text message with the ASCII scheme, and moreover suppose that this plaintext is 10 gigabytes long, therefore (using an OTP) the key must be the same length, 10 gigabytes. I think, however, this is a ''sustainable price'' because I'm sure that the ciphertext can't be attacked.  Practically, I don't understand why having such long keys with an OTP is a big disadvantage if we reach "the dream"-- namely, perfect secrecy. Nowadays the storage of information is very easy, so what is the real problem? I can, for example, share the "long key" in person. Performance of Non Clustered Indexes on Heaps vs Clustered Indexes Drawing Mechanical Systems in LaTeX Does a photon exert a gravitational pull? I am generating one report where I need to use background image. But I found that image always starts leaving some margin space to left side.    \documentclass{article} \usepackage{wallpaper} \usepackage{mdframed} \usepackage[top=2cm, bottom=2cm, outer=0cm, inner=0cm]{geometry} \begin{document}  Some content \ThisLRCornerWallPaper{1.0}{image.jpg} \end{document}    How can I use background image covering whole page? Extreme of $\cos A\cos B\cos C$ in a triangle without calculus. If $A,B,C$ are angles of a triangle, find the extreme value of $\cos A\cos B\cos C$.   I have tried using $A+B+C=\pi$, and applying all and any trig formulas, also AM-GM, but nothing  helps.  On this topic we learned also about Cauchy inequality, but I have no experience with it.  The answer according to Mathematica is when $A=B=C=60$.  Any ideas? Is it possible to add new predictions/autofill in Overleaf? For example, when I use the command (in Overleaf/ShareLaTex):  \begin{figure}[H]     \centering     \includegraphics{some_graphic}     \caption{some_caption}     \label{fig:some_label} \end{figure}   the \includegraphics{} comes without the [] parameter to change the size of the image, and \begin{figure} without the [H] option by default.   Is it possible to renew the command to make it default? By that I mean that when I type the \begin{figure} command it adds the [H] and [h] as well as [width=\textwidth] in the \includegraphics command, rather than making a global change in the preamble e.g. How to replace all occurrences of a string in JavaScript?