• 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 purpose

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marker Interface is the empty interface.What is their purpose?
 
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically, marker interfaces are used to indicate that a class supports a special Java language functionality, but (unlike normal interfaces) this functionality isn't expressed solely through its method definitions.

Prior to Java 1.5, there was no way to describe a class's properties beyond the standard modifiers (public, private, etc), so marker interfaces were used for this purpose. Admittedly, it does feel a bit like a hack, because it's seems strange that Java assigns special meanings to a few interfaces (java.io.Serializable, java.lang.Cloneable, java.rmi.Remote, etc). Java 1.5 introduced annotations, which (in my opinion) would have been a far better mechanism for these purposes, if annotations had existed when Java was first released.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question was asked just yesterday; see here for the answer.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic