Solved

how to create our own marker interface?

Posted on 2011-03-20
8
753 Views
Last Modified: 2012-08-13
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
Comment
Question by:haneef_nb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 35178067
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
 

Author Comment

by:haneef_nb
ID: 35198564
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 40

Expert Comment

by:gurvinder372
ID: 35198604
Yes, you can.

All you have to do is make a simple interface, but the interface will have no member and method declarations
0
 

Author Comment

by:haneef_nb
ID: 35198723
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
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35198754
In that case, Yes, it is an immutable class, since it cannot be mutated (or evolved or change)
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 35202697
> 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
 

Author Closing Comment

by:haneef_nb
ID: 35376555
Thanks...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
A solution for Fortify Path Manipulation.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question