haneef_nb
asked on
how to create our own marker interface?
Dear Experts
Please explain briefly how to create a user defined marker interface, and how JRE know it is a marker interface, explain the flow also
Please explain briefly how to create a user defined marker interface, and how JRE know it is a marker interface, explain the flow also
theres nothing special about a marker interface, its just an interface with no methods defined
The JRE does not treat it any differently, your application code would use it to check if an object implemented it and treat it accordingly
The JRE does not treat it any differently, your application code would use it to check if an object implemented it and treat it accordingly
ASKER
Hi Both,
Thanks for your solution,
But in this links there is no answer for my question, i am asking that, can we create a user-defined marker interface or not, if yes, please provide the example, and kindly let me know how the jre knows it is a marker interface.
Thanks for your solution,
But in this links there is no answer for my question, i am asking that, can we create a user-defined marker interface or not, if yes, please provide the example, and kindly let me know how the jre knows it is a marker interface.
Yes, you can.
All you have to do is make a simple interface, but the interface will have no member and method declarations
All you have to do is make a simple interface, but the interface will have no member and method declarations
ASKER
Hi,
No what am asking is, suppose in my class i have only getter methods, but i don't have any private & final variables, the variables are only public & non final variables, please tell me now can i call my class as Immutable, if no please tell me the reason.
No what am asking is, suppose in my class i have only getter methods, but i don't have any private & final variables, the variables are only public & non final variables, please tell me now can i call my class as Immutable, if no please tell me the reason.
In that case, Yes, it is an immutable class, since it cannot be mutated (or evolved or change)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks...
http://www.roseindia.net/java/master-java/interface.shtml
http://stackoverflow.com/questions/4540820/marker-interface