I have the following piece of code, and I'm trying to use the input entered by the user in if/else statements later on:  String userGuess = JOptionPane.showInputDialog("The first card is "      + firstCard + ". Will the next card be higher, lower or equal?");   How can I use the word they input, i.e. "higher", "lower" or "equal" outside of the if/else statement that this code is in? The code I need their answer for is:  if (userGuess == "higher" &amp;&amp; nextCard &gt; firstCard) {     String userGuess = JOptionPane.showInputDialog(null, "Correct! The current card is a "                 + nextCard + ". Will the next card be higher, lower or equal?");     correctGuesses++; }   EDIT: Thank you for your help, I figured it out!
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?
I understand that you have to have visas to enter some countries, but I was wondering whether you have to pay for each visa separately or you can get a visa to go everywhere. You see videos and lists on what you should pack to travel the world, but no lists on the documentation needed. Suppose we have a sample of size n= 9, where the sum equals 27, and the sum of the squaredvalues equals 113. Sample mean is 27/9=3 and mean of squared values is 113/9 = 12.56 Can we then say that the sample variance $S^2 = E(\overline X^2) - E(\overline X)^2 = 12.55 - 9 = 3.56$ ? Replace unknown reference (?) with the tag from \ref or \cite Was unable to find rationale for separate tags accros SE sites.   Tag function According general definition in information systems, a  (such as an Internet bookmark, digital image, database record, or computer file). This kind of metadata helps describe an item and allows it to be found again by browsing or searching. Tags are generally chosen informally and personally by the item's creator or by its viewer, depending on the system, although they may also be chosen from a controlled vocabulary.  On SE - the same:  is a () word or phrase that describes the topic of the question help you identify  or relevant to you.  tag origin and quality  Where from tags are originated and what are tag quality parametres?  problems and contradictions examples related with SE tags  Humanity is facing information overload.  are created for collecting and sharing personal knowledge on questions or problem solving. But tag's descriptions are not matter of personal knowledge - it's just matter of , i.e. vocabulary/dictionary, or taxonomy/ontology or, speaking in general, human lexic conceptual apparatus / framework. So why time has to be spent on fact's duplicating and sharing?  At the same time We are living at the linked data times. IMHO it's the biggest blunder having same tags with different descriptions in different SE sites unlinked. Tags (and so - descriptions) should be unified.  So I'm calling to unify all tags across SE sites as feature request. Maybe automatic linking to Wikipedia and/or some other decent dictionary would be reasonable.  solution examples  This is not a duplicate of How to check if installing a package will require a reboot? Reproducible LaTeX builds - compile to a file which always hashes to the same value Can I mount the root (system) filesystem as writable in Big Sur? Create an instance of a class from a string Is there a way to create an instance of a class based on the fact I know the name of the class at runtime. Basically I would have the name of the class in a string. Let me edit a post in the close review, then vote to close it I think we need a button that says Edit and Close added to the Review Close button options.  Many of these closed posts will be around forever (and should be, closed should not just be a path to deletion), so they need editing.  If I edit it now it goes away, with the only option being a back click to get back to the review, and then click into the post and edit it.  We have an Edit and Reopen button, so this would fit in just fine. Celebrating the same new year several times over? Find and replace text within a file using commands How can I find and replace specific words in a text file using command line? How do I install HP P1102W printer driver I've got an HP Pavilion Touchsmart notebook that came with Windows 8. I've upgraded to 8.1, and now I want to dual-boot an Ubuntu distribution with Windows 10. When dual-booting with Windows 8.1, the Windows Boot Manager always took priority, even after installing GRUB. What do I need to do to get GRUB to be the default bootloader instead of Windows Boot Manager? What is the Taylor series of $$\ln \frac{1-x^2}{1+x^2}$$   ?   I started by evaluating the first derivatives but the more I go, the more complicated they are and I can't identify a pattern. How do I catalog files on several external hard drives that I want to store off-line? I have quite a few external hard drives that I want to store off-line, and possibly off-site.  The contents is not saved in a structured manner, however; basically  there's lots of project data for lots of projects.  Is there any software for Windows XP that will catalog all the hard drives, so I can search the catalog, find the files, and get the ID of the disk that has the content? Modify a class definition's annotation string parameter at runtime so I am trying to show that $f(x)$ divides $g(x)$ for all polynomials $g(x)$ satisfying that $g(A)=0$ where $f(x)$ is the minimal polynomial of a square matrix $A$.  I know from my professor that $f(x)$ is the minimal polynomial of $A$ so $f(A)=0$ so then $g(A)=0$. Therefore, $f(x)$ divides $g(x)$, i.e. $g(x)=f(x)h(x)$ where $h(x)$ is some other polynomial.  My prof told us to solve this question we need to let $b(x)=gcd((f(x),g(x))$ and by using Bezout's Identity, we need to show that $b(A)=0$. I am just having a little trouble trying to prove this. I know that this identity says:     For two polynomials $f_1(x)$ and $f_2(x)$, there exist polynomials   $g_1(x)$ and $g_2(x)$ such that $g_1(x)f_1(x) + g_2(x)f_2(x) = &gt; gcd(f_1(x), f_2(x))$.   And the uniqueness of minimal polynomial theorem is:     For a square matrix $A$, if $f_1(A) = f_2(A) = 0$ for two polynomials   $f_1(x)$ and $f_2(x)$, then $g(A) = 0$ for $g(x) = gcd(f_1(x), &gt; f_2(x))$. So the minimal polynomial of $A$ is unique up to a scalar.   So since $f(x)$ is already the minimal polynomial, I know that the $deg(b(x))=deg(f(x))$. I know how to prove the Bezout identity using the Euclidean algorithm, I'm just not exactly sure how I would show all of this using the notation he gave us of $b(x)=gcd((f(x),g(x))$. Any help at all would be appreciated. How to disable or uninstall Microsoft Edge in Windows 10 How does the telepathy supernatural ability work? I've been working on the Android SDK platform, and it is a little unclear how to save an application's state. So given this minor re-tooling of the 'Hello, Android' example:  package com.android.hello;  import android.app.Activity; import android.os.Bundle; import android.widget.TextView;  public class HelloAndroid extends Activity {    private TextView mTextView = null;    /** Called when the activity is first created. */   @Override   public void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);      mTextView = new TextView(this);      if (savedInstanceState == null) {        mTextView.setText("Welcome to HelloAndroid!");     } else {        mTextView.setText("Welcome back.");     }      setContentView(mTextView);   } }   I thought it would be enough for the simplest case, but it always responds with the first message, no matter how I navigate away from the app.  I'm sure the solution is as simple as overriding onPause or something like that, but I've been poking away in the documentation for 30 minutes or so and haven't found anything obvious.