- Use the below sample code to create an object for an interface. This is called as "anonymous inner class".
public interface MyInterface {
public void myMethod() ;
}
...
MyInterface myIntfObj = new MyInterface() {
public void myMethod() {
....
}
};
myIntfObj.myMethod();
No comments:
Post a Comment