I have an abstract parent class, and I would like it to force all subclasses to implement toString() method.
However putting:
public abstract String toString();
is causing a compilation error:
Repetitive method name/signature for method 'java.lang.String toString()' in class ...
I believe this might be caused by groovy already having toString defined.
Thanks
The
toString()is part of thejava.lang.Objectclass which already has a default implementation for it. So you essentially can’t force the sub-classes to implement it. If you want to force this kind of behavior (not sure why) then you can do something like below