Solved

annotations and marker interfaces

Posted on 2014-03-25
3
201 Views
Last Modified: 2014-04-29
You cannot force your subclasses to unimplement an interface. Annotations can have parameters of various kinds, and they are much more flexible than the marker interfaces.

I am reading as above. I have not understood clearly .

Are marker interfaces not  needed if annotations there. ?
please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 39954846
Basically, yes, marker interfaces are the old way of identifying a class with some extra metadata, eg. the Serializable interface is just a marker interface that, when a class "implements" that interface, marks that class as able to be serialized.

Annotations are the new way of providing this metadata. If Java was totally redesigned removing all the backwards compataible stuff, then Serializable would be an annotation that you could annotate your class with. It also states that annotations are more flexible, because in addition to just marking a class with just one piece of metadata, with annotations you are able to provide all sorts of metadata with the annotation. As just one made up example, if Serializable was done as an annotation, you could also include in the annotation the name of another class that should be used to actually perform the serialization. Also, annotations are more flexible because they can be applied to more than just classes; you can annotate methods,fields,variables,parameters,packages,etc
0
 
LVL 7

Author Comment

by:gudii9
ID: 40007009
If Java was totally redesigned removing all the backwards compataible stuff, then Serializable would be an annotation that you could annotate your class with.

Is this could be future enhancement in java which is is not existing now(make Serializeble as annotation)

please advise
0
 
LVL 7

Author Comment

by:gudii9
ID: 40020411
please advise
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…

746 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

10 Experts available now in Live!

Get 1:1 Help Now