I think you have a typo, maxElements isn't static, is it?
Because MyClass hasn't overriden equals it inherits the method from the class Object. Object.equals() does a comparation with "==" . This only will return true if the variables compared point to the same object. In our example two objects are created, though the hold the same information they are different objects.
You must place within MyClass an overriding equals like:
For more, consult the API and the Sun's
Java tutorial