I have the following code:
public class MyElement {
String name;
String type;
MyElement(String name, String type) {
this.name = name;
You should override an equals(MyElement me) function. Equals returns a boolean
Otherwise, you are checking that two items are the same instance of an object, not that their internal content is the same.
MyElement(String name, String type) {
this.name = name;
this.type = type;
}
public boolean Equals(MyElement me) {
return this.name.equals(me.name) && this.type.equals(me.type);
}