Solved

how to create our own marker interface?

Posted on 2011-03-20
8
745 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

747 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

13 Experts available now in Live!

Get 1:1 Help Now