I am studying Java and trying to make a little game of life game, but i have a problem with one of my methods returning a value that's supposed to change when the if statement is met. Here's the code:       int cont=0;     while (!meetscondition(s,condition, cont)){         cont++;     }      public boolean meetscondition(Scanner s,StringBuilder condition, int cont){     boolean valid= false;      switch (cont){         case 0:              System.out.println("Something something");             break;         default:              System.out.println("Something if they repeat the mistake");              break;     }      condition.append(s.next());      if (condition.toString() == "something"){         valid = true;     }      return valid;  }   The condition is never met, i've tried to make a String instead of the StringBuilder but it acts the same, as if the if were not there. Somehow the loop never ends even if you enter "something" the boolean is still false, so clearly something's not working as intended. Thanks for the read.
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?
Official way to ask jQuery wait for all images to load before executing something In jQuery when you do this:  $(function() {    alert("DOM is loaded, but images not necessarily all loaded"); });   It waits for the DOM to load and executes your code. If all the images are not loaded then it still executes the code. This is obviously what we want if we're initializing any DOM stuff such as showing or hiding elements or attaching events.  Let's say though that I want some animation and I don't want it running until all the images are loaded. Is there an official way in jQuery to do this?  The best way I have is to use &lt;body onload="finished()"&gt;, but I don't really want to do that unless I have to.  Note: There is a  in Internet Explorer which actually does wait for all images to load before executing code inside $function() { }. So if you're using that platform you'll get the behavior I'm looking for instead of the correct behavior described above. Can I visit UK with Italian stay permit? I'm an Egyptian citizen, who holds Schengen visa and stay permit in Italy. Can I go to UK for some days with my stay permit and Schengen visa? \textcite macro produces "Author (year)" correctly but colours first paren with hyperref I am using a custom \textcite macro that I found somewhere. It works nicely except that it makes the opening paren of "Author (year)" part of the link (also colouring it blue) which is not desired.  This is likely just a minor change to the definition of the macro, but the solution eludes me (I don't get where the opening paren is added at all).    Opening paranthesis should not be part of link and should not be coloured.  (M)WE:  \documentclass{scrartcl}  \usepackage{csquotes}  \usepackage[backend=biber,             bibencoding=utf8,             hyperref=true,             natbib=true,             minnames=1,     %% prevent truncation to year-only             backref=true, %% TODO REMOVE before final             bibstyle=apa,             citestyle=authoryear,             ]{biblatex} \DeclareLanguageMapping{english}{english-apa} \addbibresource{bib.bib}   \DeclareCiteCommand{\textcite}   {\boolfalse{cbx:parens}}   {\usebibmacro{citeindex}%    \printtext[bibhyperref]{\usebibmacro{textcite}}}   {\ifbool{cbx:parens}      {\bibcloseparen\global\boolfalse{cbx:parens}}      {}%    \multicitedelim}   {\usebibmacro{textcite:postnote}}   \usepackage[table,svgnames]{xcolor}  \definecolor{solblue}{HTML}{268BD2}  \usepackage[pdftex]{hyperref}  \hypersetup{    pdfhighlight = /P,    colorlinks=true,    urlcolor=solblue,    filecolor=solblue,    linkcolor=solblue,    citecolor=solblue,    raiselinks=true,    breaklinks,    unicode }   \begin{document}  foobar \textcite{thesis_pockrandt} foobar  \end{document}   bib.bib:  @phdthesis{thesis_pockrandt,     author = {Christopher Maximilian Pockrandt},     title = {{Approximate String Matching: Improving Data Structures and Algorithms}},     year = {2019} } I've been working a bash script to automate the process of opening and closing an LVM over LUKS external hard drive. However I continue to receive errors on line 28:   $(vgchange -a n ; cryptsetup luksClose vol)   The error I receive:  $ sudo ./encryption.sh -l Locking System.............. ./encryption.sh: line 28: 0: command not found System Locked!   Here is the rest of the code for reference:  if [ $1 = -u ] ; then     $(cryptsetup luksOpen /dev/sdb2 vol)     echo "Unlocking.................." | pv -qL 10     $(mount /dev/mapper/vol-lvroot /mnt ; mount /dev/mapper/vol-lvvar /mnt/var ; mount /dev/mapper/vol-lvhome /mnt/home ; mount /dev/sdb1 /mnt/boot)     echo "System Mounted!" | pv -qL 10 #   exit 0 fi  if [ $1 = -l ] ; then     $(umount /mnt/var ; umount /mnt/home ; umount /mnt/boot ; umount /mnt/)     echo "Locking System.............." | pv -qL 10     $(vgchange -a n ; cryptsetup luksClose vol)     echo "System Locked!" | pv -qL 10     exit 0 fi   Other information:   I receive no apparent error when running the command in question by itself interactively. I'm new to writing bash, so any recommendations and constructive criticism is appreciated. The process appears to complete successfully, but I don't understand the error or how to make them go away. Upon further research when running the troubled code alone in interactive mode it does provide output after being executed.   This is given after posting the troubled code interactively.   0 logical volume(s) in volume group "vol" now active Media keys behaving like function keys Credit cards: How is a cash advance different from a purchase? Why are the fees so high? How can you construct the bijection between real numbers and functions over naturals? I'm struggling to understand the concept of quantum entanglement. I've distilled my understanding into an analogy, and I need your help to validate it. Here it is:  Let's say I receive two envelopes. Both envelopes have this written on them:     Hello! Open this letter...   If the paper inside is red, then other envelope has blue paper.   If the paper inside is blue, then other envelope has red paper.   So, if I open one letter, and the paper inside is red, then I know the other letter contains the blue paper.  Is this equivalent to quantum entanglement? The fact that I will know the color of the other paper when I open (i.e. observe) one envelope?  In theory, if one of the letters "appeared" in a different galaxy, I would still know the color of the paper inside that letter, just by opening my letter, instantly, correct?  Before I open the letter, is the paper inside each envelope in superposition (??), i.e. 50/50, red or blue?  In this analogy, I am assuming that what's written on the letters is true. Is this a correct assumption in quantum physics? I think so yes?  In real quantum physics, would I be able to change the color of one paper, so that I change the color of the other one? No right? Tricks and tips for finding information in man pages Does anyone have any tricks and tips for finding information in man pages? Fixed points under action of conjugate group elements Lecture notes:  If $g$ and $h$ are conjugate then $fix(g)=fix(h)$. To see this, say $g=k^{-1}hk$  If $g.s=s \iff k^{-1}hk.s=s \iff h.(k.s)=(k.s)$  Me: I understand the last line- I just fail to see how it implies $fix(g)=fix(h)$  EDIT: As Ben S says I think there was a typo in the notes and they forgot modulus signs so- New Aim: show $|fix(g)|=|fix(h)|$ What order should Asimov's Foundation series be read in? Let $\mathbf A, \mathbf B$ be Hermitian matrices of the same size. What is the characterization of $\mathbf A, \mathbf B$ such that $p(\lambda)=\det(\mathbf A-\lambda\mathbf B)=0$ has only real roots?   If $\mathbf B$ is positive definite (I corrected this), it is easy to see $p(\lambda)$ has only real roots. Most OO languages prefix their interface names with a capital I, why does Java not do this?  What was the rationale for not following this convention?  To demonstrate what I mean, if I wanted to have a User interface and a User implementation I'd have two choices in Java:        Class = User, Interface = UserInterface   Class = UserImpl, Interface = User      Where in most languages:     Class = User, Interface = IUser   Now, you might argue that you could always pick a most descriptive name for the user implementation and the problem goes away, but Java's pushing a POJO approach to things and   most IOC containers use DynamicProxies extensively.  These two things together mean that you'll have lots of interfaces with a single POJO implementation.  So, I guess my question boils down to: "Is it worth following the broader Interface naming convention especially in light of where Java Frameworks seem to be heading?" Let $A_n$ denote an $n \times n$ tridiagonal matrix.  $$A_n=\begin{pmatrix}2 &amp; -1 &amp; &amp; &amp; 0 \\ -1 &amp; 2 &amp; -1 &amp; &amp; \\ &amp; \ddots &amp; \ddots &amp; \ddots &amp; \\ &amp; &amp; -1 &amp; 2 &amp; -1 \\ 0 &amp; &amp; &amp; -1 &amp; 2 \end{pmatrix} \quad\text{for }n \ge 2$$  Set $D_n = \det(A_n)$  Prove that $D_n = 2D_{n-1} - D_{n-2}$ for $n \ge 4$. optimality of the Carnot cycle It is well-known and is stated always and everywhere that the Carnot cycle is the most efficient thermodynamic cycle. Although stated as such it is rarely proven. One proof is in the article &quot;Engine Efficiencies and the Second Law of Thermodynamics&quot;, (AMERICAN JOURNAL OF PHYSICS VOLUME 37, NUMBER 11 NOVEMBER 1969), Tobin proves that among all engines performing a cycle, so that the engine returns to its starting state, the Carnot cycle is the most efficient where efficiency is defined as $\epsilon= 1-\frac{Q_{rejected}}{Q_{absorbed}}$, and the Carnot cycle is defined as one consisting of an isothermal-adiabatic-isothermal-adiabatic segment. The proof assumes the Clausius equality, that is in a reversible cycle $\oint \frac{\delta Q}{T} = 0$. Then using the geometry of the picture below a simple argument over the areas enclosed in the cycles IABCDJI vs. IAEFGDJI (heat absorbed) or IJDAI vs. GHEAIJDG (heat rejected) will show that any other cycle working between the same temperature limits such as EFGHE will have lower efficiency than the Carnot cycle ABCDA. But this proof assumes tacitly that pieces EFG and GHE are such that $dS&gt;0$ and $dS&lt;0$, respectively. Here I am thinking of a nasty cycle such as shown in the next figure in red where the cycle cannot be neatly separated into two and only two monotonic parts having $dS&gt;0$ or $dS&lt;0$. There is no obvious reason why that restriction should hold in general. Clearly this monotonicity should hold if the engine has only temperature as its independent &quot;force&quot; but if the engine's state needs more than one independent force variable than the situation is more complicated. Instead it is reasonable to assume that any physical cycle should have finite number of monotonic pieces, kind of a &quot;thermodynamic Dirichlet condition&quot; but it could also have self intersections, little loops, and other ugly features when projected on the TS plane. How would then one prove the optimality of a Carnot cycle? Or ugly cycles on the ST plane are non-physical even if there are more than one thermodynamic variables? [] [] Proof that $\gcd(ax+by,cx+dy)=\gcd(x,y)$ if $ad-bc= \pm 1$ I'm having problems with an exercise from Apostol's Introduction to Analytic Number Theory.     Given $x$ and $y$, let $m=ax+by$, $n=cx+dy$, where $ad-bc= \pm 1$. Prove that $(m,n)=(x,y)$.   I've tried to give a proof, but I suspect it's wrong (or at least not very good). I would be very thankful for any hints/help/advice!  My proof:     We observe that since $ad-bc= \pm 1$, $ad=bc \pm 1$, and $(ad,bc)=1$.   Now, $(a,b) \mid m$ and $(c,d) \mid n$ but      $$(a,b) = ((d,1)a,(c,1)b)=(ad,a,bc,b)=(ad,bc,a,b)=((ad,bc),a,b)=(1,a,b)=1.$$      Similarly, we determine $(c,d)=1$. So, $1=(a,b) \mid m$ and $1=(c,d) &gt; \mid n$. But $(x,y)$ also divide $m$ and $n$. Since $(x,y) \geq (a,b)=(c,d)=1$, this implies that $(x,y)=m,n$. Hence   $(m,n)=((x,y),(x,y))=(x,y)$. Detect the Internet connection is offline? How to detect the Internet connection is offline in JavaScript? $(S^1 \times [0,1])/\sim$ homeomorphic to unit disk $ D^2$ Let $\sim$ be the equivalence relation on $S_1 \times I$ given by $(x,t)\sim(y,s)$ if and only if $xt=ys$ where $I=[0,1]$  How do I prove that $(S_1 \times I)/\sim$ is homeomorphic to the unit disk $D^2$ with the induced topology? What to do when OP answers his/her own question in an edit? Reference question:   Sometimes users solve their own questions, which is great. Sometimes they say they've solved it and move on, which is not so great. The above question is middle-ground: the user posted an answer to his own question, but as an edit to the question instead of as a real answer.  Should any action be taken in such a case? The obvious solution is to copy the edit into a real answer. But is this the right solution? In this case, the answer is a little hidden and there are no other answers, so it appears on the unanswered list.     Related: How to download all required Ubuntu drivers