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 -

jquery - Keeping Kendo Datepicker in min/max range -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -