• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

marker interface

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have confusion in using marker interface..what's the functionality of marker interface..
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Apex han wrote:I have confusion in using marker interface..what's the functionality of marker interface..


They are interfaces with no methods. They tell the compiler to treat the classes implementing them differently. They usually used to categorize the classes based on their purpose. Good examples of these are: Serializable , Clonable.

Found an useful link: Are Marker Interfaces Dead?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mohamed sanaullah wrote:They tell the compiler to treat the classes implementing them differently.



No. They do not tell the compiler anything. They are not magical in any way. For every use of a marker interface -- Serializable, Cloneable, or any other -- there is plain old Java code somewhere doing something like



That is all. Compilers know nothing about them. The JVM itself knows nothing about them.


Found an useful link: Are Marker Interfaces Dead?



Although some of what this article says is true, it contains the mistakes made in the post above, so far from considering it useful, I'd consider it harmful.
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for clearing the doubt. I knew that they are empty interfaces and had a fair idea about it. But yeah its foolish of me to actually believe most of the article. Considering it was on DZone- I thought it would have relevant information.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic