Solved

how to create our own marker interface?

Posted on 2011-03-20
8
751 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 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
How our DevOps Teams Maximize Uptime

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

 
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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java string replace 11 61
JavaFX TableView not displaying correctly 3 105
CSV file parsing thru Java 13 39
DTD and JAVA versions 1 29
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.

756 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