//The test determines whether the object at the left argument implements the specified interface.
publicclass MainClass {
publicstaticvoid main(String[] argv) {
MyClass myObject = new MyClass();
if (myObject instanceof MyInterface) {
System.out.println("myobject is an instance of MyInterface");
}
}
}
interface MyInterface {
publicvoid myMethod();
}
class MyClass implements MyInterface {
publicvoid myMethod() {
}
}