Thursday, March 29, 2018

How can instantiate Java interface without implementing.

public interface Foo { String method(); }
public class Claaa {
   public static void main(String[] args) {
    Foo fooByIC = new Foo() {
       @Override
       public String method() {
          return null;
       }
    };
  }

Answer: Inner class

No comments:

Post a Comment

How can instantiate Java interface without implementing.

public interface Foo { String method(); } public class Claaa {    public static void main(String[] args) {     Foo fooByIC...