I am working on a project that involves me using a
of a class I made, which I will name
. I defined the stated
HashSet<Test> t = new HashSet<Test>(); t.add(new Test("asdf", 1)); t.add(new Test("hello", 2)); t.add(new Test("hello", 3));
I tried using
t.contains(new Test("asdf", 1));
but it returns
. However, when I use a
it seems to work fine. I tried overriding the previous
declaration, but it didn’t work. I tried leaving
alone, but i still got
. I need to know what i am doing wrong?
also, i did not edit the hash function, i only changed Test.equals(Object o). It’s a simple project and since the java documentation states that it uses o.equals(this), i thought i would not have to.