In my project I have seen the performance issues if we include collection fields in hashCode() and equal() methods.Is it mandatory to include or not? Below is the sample program.  Student.java  public class Student {     int no;     String name;     String adress;     Set &lt; Parent &gt; parent;         public int hashCode() {         final int prime = 31;         int result = 1;         result = prime * result + ((adress == null) ? 0 :         adress.hashCode());         result = prime * result + ((name == null) ? 0 : name.hashCode());         result = prime * result + no;         result = prime * result + ((parent == null) ? 0 :         parent.hashCode());         return result;     }       public boolean equals(Object obj) {     if (this == obj)         return true;     if (obj == null)         return false;     if (getClass() != obj.getClass())         return false;     Student other = (Student) obj;     if (adress == null) {         if (other.adress != null)             return false;     } else if (!adress.equals(other.adress))         return false;     if (name == null) {         if (other.name != null)             return false;     } else if (!name.equals(other.name))         return false;     if (no != other.no)         return false;     if (parent == null) {         if (other.parent != null)             return false;     } else if (!parent.equals(other.parent))         return false;     return true; }        }
What issues / pitfalls must be considered when overriding equals and hashCode?
At the start of A New Hope, when the corvette is being attacked, C3PO says something to the effect of:     There'll be no escape for the princess this time.   But when Luke stumbles onto Leia's message in R2D2, C3PO seems to not know who the figure in the message is:     I'm afraid I'm not quite sure, sir. I think she was a passenger on our last voyage. A person of some importance, sir - I believe.   Is C3PO feigning ignorance to protect her, or does he really not recognize her? How to find a Java Memory Leak How do you find a memory leak in Java (using, for example, JHat)? I have tried to load the heap dump up in JHat to take a basic look. However, I do not understand how I am supposed to be able to find the root reference () or whatever it is called. Basically, I can tell that there are several hundred megabytes of hash table entries ([java.util.HashMap$Entry or something like that), but maps are used all over the place... Is there some way to search for large maps, or perhaps find general roots of large object trees?  [Edit] Ok, I've read the answers so far but let's just say I am a cheap bastard (meaning I am more interested in learning how to use JHat than to pay for JProfiler). Also, JHat is always available since it is part of the JDK. Unless of course there is no way with JHat but brute force, but I can't believe that can be the case.  Also, I do not think I will be able to actually modify (adding logging of all map sizes) and run it for long enough for me to notice the leak. How to add keyboard shortcuts? sum pair of columns based on matching fields I got a bash script to synchronize data between two computers. It works fine but I have to type my password every time the rsync command is called.   #!/bin/bash  sourceIP="192.168.178.128" sourceUser="user1" destinationUser="user2"  function sync() {      rsync --archive --progress -v -e "ssh -l $sourceUser " $sourceIP:/home/$sourceUser/$1/ /home/$destinationUser/$1 }  sync Pictures sync Music sync Videos sync Documents   How to store the password (via prompt) in a variable and pass it to rsync/ssh? I know that one can use "they" / "them" / "their" in place of "he" / "him" / "his" or "she" / "her" / "hers" when the subject's / direct object's gender is not known; for instance, just looking at the default user's about me section on Stack Exchange sites:     Apparently, this user prefers to keep an air of mystery about them   My question is what happens when someone wants to reference the subject using a pronoun instead.  Should the verb be conjugated accordingly to the pronoun? E.g.:     Apparently, they prefer to keep an air of mystery about them   Or should the conjugation be retained? E.g.:     Apparently, they prefers to keep an air of mystery about them   The former looks unclear because it wouldn't allow the reader / listener to understand if the writer / speaker is talking about a single person or about a group of people, however the latter sounds very weird, at least just to the non-native speaker which I am. I'm still making my way along in Niven's Intro to Number Theory, and the title problem is giving me a little trouble near the end, and I was hoping someone could help get me through it.  Now $x^8\equiv 16\pmod{2}$ is solvable with $x\equiv 0\pmod{2}$, so I assume $p$ is an odd prime. From a theorem earlier in the text,      If $p$ is a prime and $(a,p)=1$, then the congruence $x^n\equiv a\pmod{p}$ has $(n,p-1)$ solutions or no solution according as $a^{(p-1)/(n,p-1)}\equiv 1\pmod{p}$ or not.   So since $(16,p)=1$, the problem reduces to showing that $16^{(p-1)/(8,p-1)}\equiv 1\pmod{p}$ holds for all $p$. I note that $(8,p-1)$ can only take values $2,4,8$. For $2$, the above equivalence is then $4^{p-1}\equiv 1\pmod{p}$, which is true by Fermat's little Theorem. For $4$, it is then $2^{p-1}\equiv 1\pmod{p}$, which again holds by FlT. However, the case where $(8,p-1)=8$ is throwing me off. At best I see that $16^{(p-1)/8}\equiv 2^{(p-1)/2}\pmod{p}$, but I'm not sure how to show this is congruent to $1$ modulo $p$. Maybe there's a more elegant way to do it without looking at cases. Thanks for any insight. What color are Nissa, Worldwaker's lands? Uxie and Azelf Are Not Appearing in Nameless Cavern How do I fill a shape with text, like a circle? How do I confine text within a shape such as a circle or triangle?  I don't want text along the perimeter, I would like it to break appropriately at all the inner edges. I can seem to run scripts (.sh) with and without them being set as executable. So where exactly this matters? is there any way to decode string? What can I do if I forgot my Windows password? I got a brand new Windows 7 machine, installed the operating system, created one account and forgot its password. What can I do?  There is no external CD, the operating system is loaded from somewhere inside the machine.  I already tried to remember passwords and tried all candidates with all possible combinations of caps lock, num lock etc. First I should clarify I don't have previous experience with the field, so I don't know the technical terminology. My question is as follows:  I have two weather datasets:    The first one has the regular coordinate system (I don't know if it has an specific name), ranging from -90 to 90 and -180 to 180, and the poles are at latitudes -90 and 90. In the second one, although it should correspond to the same region, I noticed something different: latitude and longitude were not the same, as they have another reference point (in the description is called a rotated grid). Together with the lat/lon pairs, comes the following information: southern pole lat: -35.00, southern pole lon: -15.00, angle: 0.0.    I need to transform the second pair of lon/lat to the first one. It could be as simple as add 35 to the latitudes and 15 to the longitudes, since the angle is 0 and it seems a simple shifting, but I'm not sure.  Edit: The information I have about the coordinates is the following    Apparently, the second coordinate system is defined by a general rotation of the sphere  "One choice for these parameters is:   The geographic latitude in degrees of the southern pole of the coordinate system, thetap for example; The geographic longitude in degrees of the southern pole of the coordinate system, lambdap for example; The angle of rotation in degrees about the new polar axis (measured clockwise when looking from the southern to the northern pole) of the coordinate system, assuming the new axis to have been obtained by first rotating the sphere through lambdap degrees about the geographic polar axis, and then rotating through (90 + thetap) degrees so that the southern pole moved along the (previously rotated) Greenwich meridian."   but still I don't know how to convert this to the first one. Should I really have been awarded mortarboard on a Per-site meta? The  caused me to win , yey!  But wait.     [Mortarboard] Hit the daily reputation cap for the first time   Per-site metas don't have any reputation... I am confused :-)  I know why I got the badge. Should I have?  Let me rephrase. Is this behavior desirable? How strong is Superman on Krypton? When Superman goes back to visit his home planet (using his ability to travel through time, I guess), is he:    an exceptionally strong and athletic Kryptonian? just an average Kryptonian male? a weakling on account of spending a lifetime in the comparative microgravity of Earth?   A possibly related question: why is Superman so muscular? What kind of weights does he lift to stay in shape?  The answers to  are all about Superman's superpowers on Earth compared with other visitors from Krypton; I'm asking about Kal El without his superpowers.  Clarification: I'm asking about the "classic"  Superman, say late Golden to early Silver Age, roughly 1945-1960. (Yes, I know the concept evolved during those years.) I'm not sure what that would be in terms of "numbered Earths", those came along after my time. I'm pretty sure the Kryptonians of that era had no superpowers in their native milieu, nor would Kal El if he were deported in space-time to his native world. How do I pronounce "ratio 1:1"? How do I pronounce "ratio 1:1"?  Should I pronounce it "ratio 1 to 1"? Is there a way to reach a `protected` member of another object from a derived type? class MyBase {     protected object PropertyOfBase { get; set; } }  class MyType : MyBase {     void MyMethod(MyBase parameter)     {         // I am looking for:         object p = parameter.PropertyOfBase;  // error CS1540: Cannot access protected member 'MyBase.PropertyOfBase' via a qualifier of type 'MyBase'; the qualifier must be of type 'MyType' (or derived from it)     } }   Is there a way to get a protected property of a parameter of a type from an extending type without reflection? Since the extending class knows of the property through its base type, it would make sense if possible. There have been several questions already posted with specific questions about , such as when to use it and what frameworks are there for it. However,  What is dependency injection and when/why should or shouldn't it be used? I have 20 to 3o computers on my network and I have a copy of the debian packages on /var/cache/apt/archives but when I take this downloaded copy to any other machine I need to hit an "apt-get update" , How do I avoid this ? Where is the list of packages which is updated by that command stored. I need to copy them as well, and use it on a computer which is completely offline.