• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

marker interface

 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to know how marker interface works internally in java and if it is possible to define a marker interface by a normal programmer. any details?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javaranch Discussion
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no "internally"--it's just an interface like any other. Anybody can create an interface.
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As David Newton said, marker interfaces have no special internal workings. They are indeed
empty and the compiler allows you to create your own that way. Marker interfaces are used
when the interface contract can not be enforced with just method signatures. Implementing
Cloneable, for example, means that the existing clone() method provided by Object has been
overridden. You assert that proper clone() behavior is provided. Similarly, when Serializable
is implemented, the user knows that serialization and deserialization will behave as described
in the documentation. The compiler does not force you to do this.

Jim ... ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic