0

As we know that in an Interface all methods should end with a semicolon, but i came across this example in java docs.So how is it possible to write the body in method in an Interface and What does Default keyword Signifies.

public interface Animal {
        default public String identifyMyself() {
            return "I am an animal.";
        }
    }
Dark Army
  • 268
  • 4
  • 15

1 Answers1

1

Default methods are a new addition in Java 8.

Default methods enable new functionality to be added to the interfaces of libraries and ensure binary compatibility with code written for older versions of those interfaces.

Michael Lloyd Lee mlk
  • 14,561
  • 3
  • 44
  • 81