This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "marker interface " Watch "marker interface " New topic
Author

marker interface

nitinram agarwal
Ranch Hand

Joined: Jan 29, 2009
Posts: 83
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
Author
Rancher

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 ... ...


BEE MBA PMP SCJP-6
 
Consider Paul's rocket mass heater.
 
subject: marker interface
 
Similar Threads
marker interface
Java
What is advantage of marker interface?
Marker Interface
Marker Interface purpose