• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Marker Interface???

 
Rohit VG
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the use of a marker interrface if it has no contents???
eg. Serializable interface.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This gets asked a lot. Search the "Java in General (beginner)" forum, you'll find plenty of answers.
 
Ravinder S Edhan
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It's not like that 'marker interface' does nothing? If you dig inside this 'Serializable' interface, you will come to know how does this work. There are 'writeObject' and 'readObject' kind of methods hidden behind the scene.

regards
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ravinder S Edhan:

If you dig inside this 'Serializable' interface, you will come to know how does this work.


Ehm, no you won't. It is a marker interface, it has no source code that does anything. Below is a truncated version of the source code for Serializable (I've removed the comments to save space):
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Java in General (Beginner).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic