marker annotations over marker interfaces

Posted on 2011-04-26
Last Modified: 2012-05-11
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
Question by:gudii9
    LVL 47

    Accepted Solution

    LVL 92

    Expert Comment

    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.
    LVL 7

    Author Comment

    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
    LVL 92

    Assisted Solution

    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

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Suggested Solutions

    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now