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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -