Extension Method of Java

Hello Friends
Here is the example
  1. interface MyInterface {
  2. String enter(String name);
  3. default String exit(String name) {
  4. return“ Hello” + name + ”, you are using exit method of MyInterface interface”;
  5. }
  6. }
  7. public class MyClass {
  8. public static void main(String[] args) {
  9. MyInterface f1 = new MyInterface() {
  10. @Override
  11. public String enter(String name) {
  12. return“ Hello” + name + ”, you are using enter method of MyInterface interface”;
  13. }
  14. };
  15. System.out.println(f1.enter(“Aman”));
  16. System.out.println(f1.exit(“Aman”));
  17. }
  18. }
Output
Hello Aman, you are using the enter method of MyInterface interface.
Hello Aman, you are using exit method of MyInterface interface