• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

marker annotations over marker interfaces

The chief advantage of marker annotations over marker interfaces is that it is
possible to add more information to an annotation type after it is already in use, by
adding one or more annotation type elements with defaults

I was reading above staemtent. I have not understood the statement, concept behind clearly.
Please advise. Any ideas, sugestions, sample code, links, resources highly appreciated. thanks in advance
  • 2
2 Solutions
Modifying interfaces is generally not a good idea. They are strict contracts and changing them can impact on code across your application. eg. adding a new method to an interface would require all classes that mplement the interface to provide an implementation of that method.

Annotations on the other hand are more flexible, and you can add extra annotations without impacting on other areas of the code.
gudii9Author Commented:
so we can add new method to same interface with new annotation right without changing the code in parent interface, child classes right.please advise
you cannot easily change interfaces as it results in changes being required in other classes.
on the other hand you can add new annotations far more easily

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now