I am a beginner programmer and I was trying to create a random code involving scanner and objects, but I came into a problem involving scanner. Here was my code:      package jrJava.objectPracticeHome;  import java.util.Scanner;  public class Coordinator {  public static void main(String[] args) {      Scanner scanner = new Scanner(System.in);      GroceryStore groceryStore = new GroceryStore();     System.out.println("Welcome to the Zhenda Grocery Store! We sell pears, apples, and oranges!");     System.out.println("Type in 'apple', 'orange' or 'pear' to view the number of each fruit. ");      String fruit = scanner.next();      if(fruit == "apple"){         System.out.println(groceryStore.getAppleInv());     }     else if(fruit == "orange"){         System.out.println(groceryStore.getOrangeInv());     }     else if(fruit == "pear"){         System.out.println(groceryStore.getPearInv());     }    }  }   I'm sure I called the methods correctly, and no errors pop up when I run it. Please help! :P Thanks!
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?
Transform fancy usage messages in 1D string How to deal with duplicate answers posted long after first answer(s) I've been seeing this for a while now, especially on the  tag.  A user will ask a question (usually very simple, and mostly a duplicate of older questions. But that's for another day).  The user will get one or more answers that successfully answer the question. A little bit later, usually around 5-10 minutes but can be more, another user or users will come along (mostly low rep users) and post the exact same solution, sometimes changing the wording a bit, but sometimes being lifted word for word from the other answer(s).  This is slightly different from the Fastest gun in the west problem. I have nothing against answers posted in very quick succession that solve the problem. The ones I'm talking about are answers posted long after the first correct solution, that say the same thing.  A good example of this is available . All three answers say the same thing. One offers code + explanation (first answer), the second one (three minutes later) offers only code and the third one (a full eighteen minutes later) offers only a text answer.  How should answers like this be dealt with? They are adding nothing of value to the community, as the problem has already been answered. The person posting the answer could not have run into the "The other and I posted the answer so close to each other we didn't know about duplicates until after posting" problem, as there is an eighteen minute gap.   is another example. In my preamble, you'll find:  \renewcommand{\baselinestretch}{1} \renewcommand{\familydefault}{\sfdefault} \usepackage[sfmath]{kpfonts} \usepackage[mathrmOrig]{sfmath} \usepackage{amsmath} \usepackage{amssymb} \usepackage{amsfonts} \usepackage{animate} \usepackage{anysize} \usepackage{arcs} \usepackage{array} \usepackage[scale=0]{background} \usepackage{blindtext} \usepackage{calc} \usepackage{cancel} \usepackage{chngcntr} \usepackage{CJK} \usepackage{CJKspace} \usepackage{CJKpunct} \usepackage{colortbl} \usepackage{enumitem} \usepackage{epstopdf} \usepackage{etoolbox} \usepackage{fancybox} \usepackage{fancyhdr} \usepackage{float} \usepackage{framed} \usepackage{graphicx} \usepackage{hyphenat} \usepackage{ifthen} \usepackage{latexsym} \usepackage{lmodern} \usepackage{multicol} \usepackage{multirow} \usepackage{mwe} \usepackage{pgffor} \usepackage{rotating} \usepackage{tabularx} \usepackage{textcomp} \usepackage{tgheros,tgtermes,tgcursor} \usepackage{tikz} \usepackage{times} \usepackage{tipa} \usepackage{varwidth} \usepackage{wasysym} \usepackage{wboiboites} \usepackage[abs]{overpic} \usepackage[breaklinks,colorlinks=true,linkcolor=red,citecolor=red, urlcolor=blue]{hyperref} \usepackage[framemethod=TikZ]{mdframed} \usepackage[breakable, theorems, skins]{tcolorbox,empheq} \usepackage[default]{gillius} \usepackage[document]{ragged2e} \usepackage[latin1]{inputenc} \usepackage[spanish]{babel} \usepackage[T1]{fontenc} \usepackage[total={18.59cm,26.5cm},left=1.5cm,top=2.5cm]{geometry} \usetikzlibrary{matrix,arrows, positioning,shadows,shadings,backgrounds,calc, shapes, tikzmark} \usetikzlibrary{shadows.blur} \usetikzlibrary{shapes.symbols} \usetikzlibrary{patterns,fadings} \tcbuselibrary{skins,breakable,listings,theorems}    I'm trying to draw an arrow for X axis and Y axis.   \begin{tikzpicture} \draw[yellow!10, fill=blue!5](-1, -1) rectangle (7, 5); \draw[dotted] (-0.75,-0.75) grid (6.75,4.75); \node[below] at (-0.25,0){$O$}; \draw[-&gt;,black, thick] (-0.75,0)--(6.75,0); \end{tikzpicture}   But I get this error:    Additionally, if I remove -> from the options of \draw the tikz picture compiles normally. I know it is not recommended, but is it at all possible to pass the user's password to scp?  I'd like to copy a file via scp as part of a batch job and the receiving server does, of course, need a password and, no, I cannot easily change that to key-based authentication. How to buy plane tickets for job interviews? I am currently on the academic job market, and scheduling on-campus interviews with institutions that might want to hire me.  Suppose I am invited to an on-campus interview at the University of X, and must travel there by air.  They handle travel on a reimbursement basis: I buy the plane ticket, and then they reimburse me.  However, the interview is a few weeks away.  Since the job market sometimes moves fast, there is a chance that by the time of the scheduled interview, I may have already accepted another offer (say from the University of Y).  Of course I should then decline the interview at X, but I would have already bought the plane ticket.  How should I plan for this contingency?   I could buy a refundable ticket to X.  However, these are normally several times the price of a non-refundable ticket, and if I do end up traveling to X, they might balk at reimbursing me for such an expensive fare. I could buy a non-refundable ticket to X.  If I end up not going there, I could ask X to reimburse me for the cost of the ticket (or at least the "change fee" charged by the airline to let me use the ticket's value for a future flight).  However, I suspect they will be reluctant to reimburse me for a trip I'm not making, and might refuse to do so altogether, in which case I am out-of-pocket. I could wait until the last minute to buy a non-refundable ticket for X.  But it may still be expensive for them (or may exceed their limits), and the most convenient flights may be sold out. I could contact University of X and ask them for guidance.  I'm a bit hesitant to do this, as I am afraid that if I bring up the possibility that I might accept another position, they might think I am not seriously interested in theirs.   Is there a standard way to handle this situation?  This is in the United States, if it matters. Set Snap Mode with PyQGIS I am trying to set snap mode within QGIS plugin.  So far, I have tried:  QgsSnappingUtils().setSnapToMapMode(QgsSnappingUtils.SnapAdvanced)   and  QgsSnappingUtils().setSnapToMapMode(2)   without success.  QGIS Snapping options (Settings>>Snapping Options...) continue with:  Snapping mode = Current layer  Any hint? (Using v 2.14.0) What temperature should I set my water heater to? creating a tar archive without including parent directory I am trying to create a graphical program for my script.  Inside the script I use tar to create a tar archive.  From the graphical program I get the full name of file that I want to create a tar archive.  tar -cvf temp.tar /home/username/dir1/dir2/selecteddir    My tar archive includes home, username, dir1, dir2 and selecteddir while i want tar to create archive only including selecteddir. Forgive the stupid simplicity of this question, and please feel free to refer me to an older answer. I'm not quite familiar enough with LaTeX terminology to have found it.  All I want to do is set a different default format for my section titles. Instead of just being bolded and slightly larger than the main text, I'd like them to be of normal weight, the same size as the main text, and all caps.   I'm using the article class. This is a minor frustration, but I have a  that I put italics and bold into (using asterisks.)  Now I know I just just be happy that I could do it at all, but it seems to me that those should not count toward my comment char limit. Can someone give me some example code that creates a surface with a transparent background in pygame? Combinatorial proof of summation of $\sum\limits_{k = 0}^n {n \choose k}^2= {2n \choose n}$ If asking a question or giving instruction towards a group of objects where the number is unknown (and possibly could be one) what is the correct way to phrase the sentence? Which of the following sentences are more correct:     Has there been any studies regarding this and if so what has been the   conclusion?   OR     Has there been any studies regarding this and if so what have been the   conclusions? Specifying geography with cardinal directions So here in America we are in "the West".  Would this become "the Western world" or "the western world? "  I'll assume the same applies to "the East" (Asia). How can I format my active hard drive to NTFS? I'm trying to install Windows 7 with a 4GB flash drive, but my error that comes up is that my hard drive I'm trying to install on is in ext4. I need to format it to read NTFS. I can't seem to find any topics on how to format an active hard drive. I found a topic that explains how to move Ubuntu to a new drive, but it's a bit confusing to me. How do I create a decimal field in Access with Alter Table? Is it possible to call a function whose name is stored in a string in vbscript? How a module can override theme suggestion? Basically it was  but I'll reword it, as I don't want to define a new theme (reason was already given).  What I want to do: in my module I have a file node--attach.tpl.php which is a modifed version of node.tpl.php. Now I want that, if view_mode = 'attach' then this file is used. Also, theme should be allowed to override it with its own node--attach.tpl.php in theme folder. I don't think I've seen any answers to this question, but I'm curious as to why, when you have a 64-bit OS installed (ex: Vista x64), IE defaults to the 32-bit version? Are there drawbacks to using the x64 version of IE (IE8, specifically)? Number of reflexive relations defined on a set A with n elements