Search code examples
javajava-8interfacedefault

Why the use of "default" keyword in java8


In Java 8 default method implementation is introduced. My question is why the need to have default keyword in the method name/signature. Why can't it be without the default keyword just like a usual method implementation?


Solution

  • It makes the intention clear. You can't accidentally create a default implementation for a method. Just like abstract methods require the keyword, instead of just being methods without implementation.

    A safety precaution for the careless programmers.