Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to create our own marker interface?

Posted on 2011-03-20
8
Medium Priority
?
755 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 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
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:Gurvinder Pal Singh
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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

782 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