Solved

how to create our own marker interface?

Posted on 2011-03-20
8
747 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
  • 3
  • 3
  • 2
8 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35178039
0
 
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
 
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
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.

919 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now