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 -

What is the difference between data design and data model(ERD) -

ios - Can NSManagedObject conform to NSCoding -