So the answer is "NO". Here is a
test program, any comments welcome.
/*
* TestString.java
* test | int | str eauals/hashcode ==
* 1 | 100,000 | 10/10 , 9/8
* 2 | 1,000,000 | 34/33
* 3 | 10,000,000 | 285/277, 265/260, 264/303, 263/259
*
* Created on March 7, 2005, 9:38 AM
*/
package examples.colorpicker;
public class TestString {
private String id = "This is a test.";
/** Creates a new instance of TestString */
public TestString() {
}
public boolean equals(Object obj) {
if(obj == this) return true;
if(obj == null || !(obj instanceof TestString)) {
return false;
}
TestString ts = (TestString) obj;
//return ts.id.equals(this.id); //compares str length, chars, or nullity.
return ts.id.hashCode() == this.id.hashCode();
}
public static void main(String[] args) {
TestString ts = new TestString();
String sample = "This is a test.";
long start = System.currentTimeMillis();
for(int i = 0; i<10000000; i++) {
ts.equals(sample);
}
long end = System.currentTimeMillis();
System.out.println("Programs runs for " + (end - start));
}
}