Why is this equality to another object check in String.java? -


in string.java, code @ beginning of .equals() method:

public boolean equals(object anobject) {     if (this == anobject) {         return true;     }     // ... check if instance of string, etc. } 

is check purely performance reasons (i.e. not including check characters of this against itself)?

yes, is. since references same object, it's they're equal.

string = "foobar"; a.equals(a) // true 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

c# - How do I get the Nth largest element from a list with duplicates, using LINQ? -

jsp - "Sending a redirect is forbidden after the response has been committed" in sendRedirect -