Link to home
Start Free TrialLog in
Avatar of haneef_nb
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
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

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
Avatar of haneef_nb
haneef_nb

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.
Yes, you can.

All you have to do is make a simple interface, but the interface will have no member and method declarations
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.
In that case, Yes, it is an immutable class, since it cannot be mutated (or evolved or change)
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks...