Created
November 5, 2015 20:47
-
-
Save PeterMitrano/fc9ab6cc8b44e7ddbde0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean equals(Object anObject) { | |
if (this == anObject) { | |
return true; | |
} | |
if (anObject instanceof String) { | |
String anotherString = (String)anObject; | |
int n = value.length; | |
if (n == anotherString.value.length) { | |
char v1[] = value; | |
char v2[] = anotherString.value; | |
int i = 0; | |
while (n-- != 0) { | |
if (v1[i] != v2[i]) | |
return false; | |
i++; | |
} | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment