Hello I'm new in java and I was testing the follow code in a java compiler but as my understanting an interface can´t have concrete methods but this one has concrete methods and works, can you explain me why ?? and output
"Sprinting!"
interface Run { default void walk() { System.out.print("Walking and running!"); } } interface Jog { default void walk() { System.out.print("Walking and jogging!"); } } public class Sprint implements Run, Jog { public void walk() { System.out.print("Sprinting!"); } public static void main(String[] args) { new Sprint().walk(); } }
https://stackoverflow.com/questions/67029412/why-this-code-works-if-is-suppose-that-an-inteface-it-is-fully-abstract April 10, 2021 at 07:25AM
没有评论:
发表评论