• Post Reply Bookmark Topic Watch Topic
  • New Topic

Default modifier in default method

 
Paweł Baczyński
Saloon Keeper
Posts: 1953
38
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't want to sweat it but I'm just curious about one thing.

Why is default keyword required in default method?
Like in this example:Why coudn't it be written like that?What is the advantage of requiring default modifier here?
 
Campbell Ritchie
Marshal
Posts: 52580
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Presumably it is simpler to parse if you know it a non‑abstract method before you get to the {}. It also draws the user's attention to the fact that this is something unusual,viz. a non‑abstract method in an interface.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!