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