Java: Does "==" only check for reference to an object? So I was taught that “==”  only checks whether they are the same object and “equals()” checks the values of the objects.  But for Strings, I found that “==” also checks for values. For example:-      String x = "apple";     String y = "orange";     x=y;      if (x==y){         System.out.println("yes");     }else{         System.out.println("no");     }  //OUTPUT: yes   or  String x = "apple"; String y = "apple"; y = "watermelon";     if (x==y){         System.out.println("yes");     }else{         System.out.println("no");     }tem.out.println("no");     //OUTPUT: no
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?
How to use Stokes theorem in the presence of holes? find and echo file names only with pattern found What is the command to truncate a SQL Server log file? I need to empty an LDF file before sending to a colleague.  How do I force SQL Server to truncate the log? Apple Magic Trackpad multitouch configuration Could we provide some automatic feedback on (enough) unfriendly/rude comments? Why is the charge naming convention wrong? I recently came to know about the Conventional Current vs. Electron Flow issue. Doing some search I found that the reason for this is that Benjamin Franklin made a mistake when naming positive and negative charges. There is even this little comic about that   My question is, how can a naming convention be wrong? Perhaps I don't understand what is the actual mistake here, I don't know. But I don't see how a naming convention could be wrong or right. There is no right and wrong about that. It could've been any other name, like charge A and charge B.  I'll appreciate anyone can help me understand what is wrong in all this. Gauss's law not making sense If we have a point charge and outside of it we have a non-conducting Gaussian sphere, then Gauss's law says that the net flux should be zero. I agree that the total field lines coming in are equal to the number of field lines coming out, but isn't it true that the magnitude of the electric field at those segments of the sphere where the field is coming in is greater than those where it is coming out? So when we integrate, wouldn't these areas, having a greater electric field, contribute more to the net flux? I don't see why they would cancel each other out. Does Perl have PHP-like dynamic variables? Point Release upgrade from 14.04.1 to 14.04.2? I wanted to upgrade to 14.04.2 point release from 14.04.  What I did was:  sudo apt-get update &amp;&amp; sudo apt-get upgrade &amp;&amp;  sudo apt-get dist-upgrade -y   Then I wanted to upgrade to 3.16 kernel, since it wasn't done with the the above command, so what I did was:  sudo apt-get install linux-generic-lts-utopic xserver-xorg-lts-utopic libegl1-mesa-drivers-lts-utopic xserver-xorg-video-all-lts-utopic xserver-xorg-input-all-lts-utopic sudo apt-get install linux-signed-generic-lts-utopic   Now when I do:   uname -a I get   Linux Y500 3.16.0-33-generic #44~14.04.1-Ubuntu SMP Fri Mar 13 10:33:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux  cat /etc/os-release | grep VERSION= I get  VERSION="14.04.2 LTS, Trusty Tahr"   And when I do lsb_release -a I get  Distributor ID: Ubuntu Description:    Ubuntu 14.04.2 LTS Release:    14.04 Codename:   trusty   I know that uname -a and lsb_release -a both refer to different info, but why does  cat /etc/os-release | grep VERSION= show different version? How to get from Nice to Monaco by public transport? What's the simplest and cheapest way to get from central Nice, France to Monaco by public transportation? Lagrange's theorem I don't understand left coset and Lagrange's theorem... I'm working on some project so please write me anything what could help me understand it better Turnstile package I know roughly and informally what a confidence interval is.  However, I can't seem to wrap my head around one rather important detail:  According to Wikipedia:     A confidence interval does not predict that the true value of the parameter has a particular probability of being in the confidence interval given the data actually obtained.     I've also seen similar points made in several places on this site.  A more correct definition, also from Wikipedia, is:     if confidence intervals are constructed across many separate data analyses of repeated (and possibly different) experiments, the proportion of such intervals that contain the true value of the parameter will approximately match the confidence level   Again, I've seen similar points made in several places on this site.  I don't get it.  If, under repeated experiments, the fraction of computed confidence intervals that contain the true parameter $\theta$ is $(1 - \alpha)$, then how can the probability that $\theta$ is in the confidence interval computed for the actual experiment be anything other than $(1 - \alpha)$?  I'm looking for the following in an answer:   Clarification of the distinction between the incorrect and correct definitions above. A formal, precise definition of a confidence interval that clearly shows why the first definition is wrong. A concrete example of a case where the first definition is spectacularly wrong, even if the underlying model is correct. I'm trying Google's PageSpeed online service  Ironically, it's primarily highlighting Google's own services as something that needs improvement on my site  1) jQuery from Google: blocking. So I moved all javascript from &lt;head&gt; to the end of the document before &lt;/body&gt;. That helped  2) Linking to external Google Font CSS (in &lt;head&gt;): blocking. But the font is critical to the design of the page and should load before much else  3) Google Analytics: Caching is not good. (Google has set it internally to 2 hours expiration). Don't know how to change this (this is also placed at the bottom of page)  The Google Font is highlighted as a big priority to change.  How can I fix this? Where/how should I call the the font? How to get apt-cacher-ng to download AND cache packages from Apt HTTPS repositories? In-universe explanation for single line of planetary entry/departure in Star Wars Calculate line distances inside of polygons using ArcGIS for Desktop? I'm working with two data sets:   NHD polyline stream layer for my entire state HUC Watershed boundary Polygons for the entire state   I am looking for a way to calculate the total length of streams within each watershed boundary polygon, and would ideally like to have each polygon then attributed with the sum of stream miles within its boundary.  Can anyone help me? Using simple quotes "" instead of \text{} Is there a way to use newcommand or some other nice technique to transform any occurence of  "bla"   in math mode into  \text{bla}   The reason I ask is because it is easy, and doesn't interrupt the flow of reading the (La)TeX code as much.  I would like to keep Xe(La)TeX's nice quote behavior (ie it can use the regular "" instead of backticks to quote some text outside math mode). I know how to successfully duplicate an object by using  bpy.ops.object.add_named(name = 'TemplateObjectName')   If the template object named 'TemplateObjectName' has animations, particle systems and modifiers attached to it, the previous call will create a duplicate object that also has those components. However, if I duplicate an object using   template_object = bpy.data.objects['TemplateObjectName'] new_object = bpy.data.objects.new('NewObjectName', template_object.data) collection.objects.link(new_object)   how do I attach the template object's animation, modifiers, particle systems...? Detect when an iOS app is launched for the first time? How do I detect when an iOS app is launched for the first time?