Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Marker classes

 
Unnati Redkar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,


i am trying to figureout the significance of empty/marker classes in java.
In what scenario are they used?
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you mean Marker Interfaces.

Google for that term (maybe plus "java") and you'll get plenty of information.

Note that Marker Interfaces, while still used by plenty of current Java APIs, should not be created(*) in new code. If you were thinking of creating a new Marker Interface, it would usually be better to create a new type of Annotation.

(*) Note that I say "created", not "used".
 
santosh joshi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My understanding about the Marker Interfaces is that

it is just a Flag. which is tested by the compiler to do certain things

For certain things the compiler checks weather this flag is on or not
in java terms weather the Marker Interface is implemented by the class or not

for example whenever we want to serialize an Object we have to implement the Serializable interface . now when compiler sees the Markar tag( implemtts Serializable ) in a class it makes an understanding that yes this class is a candidate for serialization

There are many marker interfaces in java You just check with them

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic