This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Customer Requirements for Developers and have Marcho Behler on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes marker interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "marker interface " Watch "marker interface " New topic

marker interface

nitinram agarwal
Ranch Hand

Joined: Jan 29, 2009
Posts: 90
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

Joined: Jan 28, 2008
Posts: 5575

Javaranch Discussion
David Newton

Joined: Sep 29, 2008
Posts: 12617

There's no "internally"--it's just an interface like any other. Anybody can create an interface.
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
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 ... ...

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: marker interface
jQuery in Action, 3rd edition