Fundamentals

Default Methods

Collections

Idioms and Techniques

Design Rationale

Advanced Questions

Why do default methods need a keyword?

It is often asked why the designers felt it necessary to distinguish default methods with a keyword, given that it can—and must—be applied only to non-abstract interface methods (and that the same keyword is already used, with a different meaning, as part of the switch statement). A minimal syntax would dispense with the keyword. This issue was debated extensively during the design of the language support for lambdas; a flavour of the discussion can be gained from many of the 76 posts in the thread “Default Method Survey Results” in the August 2012 lambda-dev archive. The conclusion that the Expert Group reached is summarised in a later post: the central reason is that a keyword immediately prompts a reader’s understanding, in the same way as the strictly redundant keyword abstract does for abstract methods and classes. Since the keyword default is also strictly redundant, its inclusion clearly depended finally on subjective judgements.