• Post Reply Bookmark Topic Watch Topic
  • New Topic

Marker interface  RSS feed

 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the use of Marker interface in Java?

Regards,
aakash
 
peter greaves
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to indicate something about a class, for something that can use the reflection API. good example is servlet implements SingleThreadModel if i declare "implements SingleThreadModel", an interface whiuchn is a marker (IE has no methods) i am telling the servlet container that my servlet is not thread-safe and that a new instance should be started to handle requests. so i am giving the user of the class a message which can be tested like this:

peter
 
Gayathri Prasad
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Akash,
Marker Interface is a synonym for TagInterface.
An idiom used in Java, and possibly other languages. It's an interface that indicates the class is meant or allowed to be used for a particular purpose. A classic example is the cloneable interface in Java. Classes that "implement Cloneable" (see below) can be copied using the clone() method.
class Example implements Cloneable
Goodday,
Gaya3
------------------------------------------------
Beginning is half done
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!