• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 756
  • Last Modified:

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
0
haneef_nb
Asked:
haneef_nb
  • 3
  • 3
  • 2
1 Solution
 
objectsCommented:
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
0
 
haneef_nbAuthor Commented:
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.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Gurvinder Pal SinghCommented:
Yes, you can.

All you have to do is make a simple interface, but the interface will have no member and method declarations
0
 
haneef_nbAuthor Commented:
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.
0
 
Gurvinder Pal SinghCommented:
In that case, Yes, it is an immutable class, since it cannot be mutated (or evolved or change)
0
 
objectsCommented:
> can we create a user-defined marker interface or not,

you can

> if yes, please provide the example,

public interface MyMarker {
}

> and kindly let me know how the jre knows it is a marker interface.

Its doesn't really, it would be used by your application classes.
Has nothing to do with the JRE, it just treats it the same as any interface
0
 
haneef_nbAuthor Commented:
Thanks...
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now