I would expect that the compliler would allow you to do this since I believe it is up to the programmer to ensure the equals method is overriden. Here is a slight addition to the code I used to
test this theory:
<code>
import java.util.*;
public class HashTest{
public static void main(
String args[]) {
class Car{ }
Hashtable ht = new Hashtable();
Car c1 = new Car();
Car c2 = new Car();
ht.put(c1,"10");
ht.put(c2,"20");
System.out.println(ht.get(c2));
System.out.println("Equality test of c1.equals(c2): " + c1.equals(c2));
}
}
</code>
When I run this, it the following:
20
Equality test of c1.equals(c2): false