java - Without Implement Keyword, Can we use interface? -


can use variable , methods of interface without using keyword 'implements'.

note:interface , classes in same package.

thanks in advance..!!!

  • all variables of interface public static final default, can directly use them
  • you can implement interface means of anonymous class (without using implements keyword)

    public static void main(string[] args) throws exception{    system.out.println(i.s); // accessing interface i's variable    i = new i() {      @override     public int gets() {         return 10;     }    };    system.out.println(i.gets()); // accessing i's method }   interface {     string s = "test";     int gets(); } 

Comments