Generic way to compare class instance in Java -
i looking generic way implement code snippet:
if (!(obj instanceof myclass)) { return false; }
ideally (so don't have hard-code myclass everytime):
if (!(obj instanceof this.getclass())) { return false; }
however, example not work.
you do
this.getclass().isinstance(obj);
Comments
Post a Comment