interface Default Methods in Java


Java 8 introduced default methods in interfaces, allowing you to define a method body. This helps in evolving interfaces without breaking existing implementations.

Source Code

interface Animal {
    default void eat() {
        System.out.println("This animal eats food");
    }
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments