Java instanceof with changing objects

How about this:

public boolean checker(Object obj) {
    return obj instanceof SomeClass;
}

or if SomeClass needs to be a parameter:

public boolean checker(Object obj, Class someClass) {
    return someClass.isInstance(obj);
}

or if you want the instance to be someClass and NOT an instance of a subclass of someClass:

public boolean checker(Object obj, Class someClass) {
    return someClass.equals(obj.getClass());
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)