I'm working on deeper understanding of Java and I was experimenting with comparing the same objects.  I have created two string objects with the same value, but assigned to different variable. It turned out that they have the same hash codes.  After that I have created simple class representing person and created two instances of this class with the same parameters passed to constructor. It turned out that they have different hash codes.   Now I'm confused how does it work. Could you please explain me that?  my code:   public static class Person {          public String name;         public String lastName;          public Person(String name, String lastName) {             this.name = name;             this.lastName = lastName;         }     }      public static void main(String[] args) {          String s1 = new String("foo");         String s2 = new String("foo");         System.out.println("String1 hashcode: " + s1.hashCode());         System.out.println("String2 hashcode: " + s2.hashCode());         System.out.println("Is String1 equal to String2?: " + s1.equals(s2));          Person p1 = new Person("John", "Doe");         Person p2 = new Person("John", "Doe");         System.out.println("Person1 hashcode: " + p1.hashCode());         System.out.println("Person2 hashcode: " + p2.hashCode());         System.out.println("Is Person1 equal to Person2?: " + p1.equals(p2));      } }   my output:  String1 hashcode: 101574 String2 hashcode: 101574 Is String1 equal to String2?: true Person1 hashcode: 325040804 Person2 hashcode: 1173230247 Is Person1 equal to Person2?: false
What issues / pitfalls must be considered when overriding equals and hashCode?
Prepend phone numbers with a calling card dial in number Distance function is continuous in topology induced by the metric The question is (from Topology without tears) that: Let $(X,d)$ be a metric space and $\tau$ the corresponding topology on $X$. Fix $a \in X$. Prove that the map $f:(X,\tau) \rightarrow \mathbb{R}$ defined by $f(x) = d(a,x)$ is continuous.  My first attempt was that let an open ball, $B_{\epsilon}(a)\subset \mathbb{R}$ and show that $f^{-1}(B_{\epsilon}(a)) \subset \tau$. Since $f(x) = d(a,x)$, $f^{-1}(B_{\epsilon}(a))=B_{\epsilon}(a) \in \tau$.   I am pretty sure the last sentence is wrong. I am not sure if every open ball is an open set in topology induced by metric space.  Please give me some hint and direction. Thanks How to break out of jQuery each Loop S tabular with alignment Prove that $(n-1)! \equiv -1 \pmod{n}$ iff $n$ is prime [Wilson's Theorem] How can I show that $(n-1)!\equiv-1 \pmod{n}$ if and only if $n$ is prime? Thanks. Why do I see different versions of node and nodejs I ran the following commands to install the stable version of node  sudo npm cache clean -f sudo npm install -g n sudo npm install -g n   Now, when I run node -v, I see v10.0.0, whereas nodejs -v returns v4.2.6. As far as I'm aware, node and nodejs are the same thing. Why am I seeing this? Thanks. Will I miss anything by watching Dragon Ball Z Kai instead of the other series? I've read that Dragon Ball Z Kai is an HD remaster and recut of Dragon Ball and Dragon Ball Z. However, Kai has  while Dragon Ball has  and Z has .  If I watch only Dragon Ball Z Kai, do I miss anything I would get by watching the other two series? And is anything censored in Kai that is not censored in the others? EJB Transactions in local method-calls In the following setup, does method B run in a (new) transaction?  An EJB, having two methods, method A and method B  public class MyEJB implements SessionBean     public void methodA() {        doImportantStuff();        methodB();        doMoreImportantStuff();     }      public void methodB() {        doDatabaseThing();     } }   The EJB is container managed, with methodB in requires_new transaction, and method A in required transaction. thus:  &lt;container-transaction id="MethodTransaction_1178709616940"&gt;   &lt;method id="MethodElement_1178709616955"&gt;     &lt;ejb-name&gt;MyName&lt;/ejb-name&gt;     &lt;method-name&gt;*&lt;/method-name&gt;   &lt;trans-attribute&gt;Required&lt;/trans-attribute&gt;   &lt;/method&gt;   &lt;method id="MethodElement_1178709616971"&gt;     &lt;ejb-name&gt;MyName&lt;/ejb-name&gt;     &lt;method-name&gt;methodB&lt;/method-name&gt;   &lt;/method&gt;   &lt;trans-attribute&gt;RequiresNew&lt;/trans-attribute&gt; &lt;/container-transaction&gt;   Now let another EJB call methodA with an EJB method call. methodA now runs in an transaction. Will the subsequent call to methodB from methodA run in the same transaction, or does it run in a new transaction? (mind, it's the actual code here. There is no explicit ejb-call to method B) CPU time out limit was being hit while processing child records on the inline opportunity visualforce page, to handle this i wrote a remoteActionFunction on the page that invokes controller method that's taking long to process and when i get CPU LIMIT exception in the result, i am invoking javascript call back function that invokes a action function which handles the same code asynchronously(@future).  Question: by setting the timeout (Visualforce.remoting.timeout = 120000;) can't we overcome CPU TIME out limit of 10,000 ms. Consecutively Adding Sines One thing, I'm not a mathematician so please be patient. I am still in Algebra II Trig. Leading with that, why does  $$ x_0 = \sin 1, \space  x_1 = x_0 + \sin x_0, \space x_2 = x_1 + \sin x_1 ... $$ and after a while, $$ x = \pi $$  I know this to be true because I have evaluated this on my TI-84 and more deeply evaluated it with this program I made:   To $100000$ Iterations (which I believe is enough)   So what's the math behind it? Why does adding $\sin 1$ in this manner produce $\pi$? Why doesn't doing the same thing using $100$ produce $\pi$? For example,  $$\sin(1) = 0.841470...,\space \sin(1) + \sin(0.8414...), \sin(1) + \sin(0.841470...) + \sin(1.587095126...),\space ... $$ $$ = \pi$$  My question is different from the mentioned because my function is not taking the sin of a sin consecutively, but is this following function: $f(x) = x + \sin x$ and is not $f(x) = \sin x$ and therefore can exhibit different properties I need explained. I needed to change the SID of an Oracle XE database (not the Service Name) to match a production database.  When I tried searching online, most of the pages were describing changing or adding a service name through tnsnames.ora; that's not what I needed to do. I've seen the word static used in different places in C code; is this like a static function/class in C# (where the implementation is shared across objects)? Why is "No new release found" when upgrading from a LTS to the next? Scroll to bottom of div? I am creating a chat using Ajax requests and I'm trying to get messages div to scroll to the bottom without much luck. I am wrapping everything in this div: #scroll {     height:400px;     overflow:scroll; }  Is there a way to keep it scrolled to the bottom by default using JS? Is there a way to keep it scrolled to the bottom after an ajax request? Looking for a SF story regarding women growing things in their wombs I'm looking for the title and author of a short story or novelette that I read quite some time ago.   The main characters are two young women. One is taking correspondence courses, and is constantly being berated by the other one for hoping to rise above her station. They go out to pick up young men, to sleep with them, to get pregnant.  It's not a normal sort of pregnancy, though. The men have some sort of 'coded semen' which grow something other than a child in the woman's womb. It ends up being a product of some kind, which earns the woman money when it is 'born'. The one woman is very careful about who she chooses, as she can only do this so many times. The other... isn't so careful.   At the end, the careful, studious woman achieves what she has been working for - a letter from a government organisation that permits her to become the mother to a human being.  Thank you for reading my question. I've been looking for this story for years, now. How is Cooper's age justified? Is there a word to describe someone who tends to disagree with others only to upset them? What's the word to describe someone who acts arrogantly and always disagrees with others unreasonably in order to upset people around him/her?  [I'm not looking for adjectives like unpleasant, annoying, unfriendly, rude, I'm looking for a more specific term like opinionated, didactic, loquacious, gregarious ]  I think I'd come across it before but I've forgotten what it is.. Cannot make a static reference to the non-static method I want to run DFS replication between a couple of servers. It's my understanding that the servers need to be part of a domain for this. Being able to give people a username and password that works on all servers would be useful too, so I can lock up the admin password.  All machines will be running Windows 2008R2 and they will all be running Windows Firewall, so I need to be able to allow the other machines to connect to this server, but lock out everyone else.   So my question is: what ports do I need to allow the machines to connect to the Domain Controller over? Solve for $f(x)$ if $f(f(x))=6x-f(x)$ If $f: [0,\infty) \rightarrow [0,\infty)$ and   $f(f(x))=6x-f(x)$ $f(x)&gt;0$ $  \forall x \in (0,\infty) $   Find f(x)