-
Contributing Member
marker interface....
What is marker interface ? What is the use for that one ?
------------------
suresh
-
Junior Member
Re: marker interface....
An empty interface is known as a "marker" interface in Java. A class implementing this has a certain feature/property about it. E.g Serializable interface. Any class implementing this is serializable. Same with Cloneable interface.
Interface containing methods is normal Java interface and these methods must be implemented by any class which wishes to implement that interface.
Hope this helps.
-
Contributing Member
Re: marker interface....
What is the use of empty interface ? From your answer, i think the use for this to identify the class contains serializable or Cloneable etc...
But this is the only use then why they create interface ? They can easily design a java reserved keyword and then implement it...
Why they particularly design a interface to acheice this goal ?
-------------------
suresh
-
Junior Member
Re: marker interface....
Java interface which doesn't actually define any fields. It is just used to "mark" Java classes which support a certain capability -- the class marks itself as implementing the interface. For example, the java.lang.Cloneable interface.
To let the system know that some action can be formed on a class that implements the marker?
Serializable --> Class be serialized using serialize()
Cloneable --> Class can be cloned using clone()
Last edited by chg81713; 01-31-2007 at 03:31 AM.
-
-
Junior Member
Re: marker interface....
marker doesnt have methods but they accomplish the task if a class implements the marker interface,Any interface without a method acts like a marker. They just tell the compiler that the objects of the class implementing the marker interface has to be treated differently. Example Its used in the process of serialization. To send an object over network or if the state of the object has to be persisted to a flat file or a database. Deep cloning can be achieved through serialization. This may be fast to code but will have performance.
-
Junior Member
Re: marker interface....
Hi suresh,
Technically any java object that implements java.rmi.remoteinterface this interface is a marker interface or tag interface, you know which doesn't contain any methods.A marker interface is usually used to indicate a specially features related to our class to the JVM.
regards,
vardhan.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules