For this example:
public class Foo{} public class Bar extends Foo{} .... void myMethod(Foo qux){ if (checkInstance(qux,Foo.class)){ .... } }
you should use instanceof
if(qux instanceof Foo && !(qux instanceof Bar)) { ... }
This works with both classes and interfaces, so in most cases it should preferred over .class which does not work with interfaces.
.class