• 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

Interface(marker)

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any object that implements the java.io.Serializable interface can be made as serialazable., that means JVM performs serialization internally...Similarly if i define a marker interface, how would JVM know what task to be performed on behalf of my marker interface. How should i intimate the JVM about the task that should be performed by it, if any object implements my marker interface?
 
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
Here's how marker interfaces work: some code, somewhere, knows to do this:



You can define a marker interface of your own, and write code of your own like the above, but of course you can't somehow get the JVM to automatically do anything. But that's all that the Serializable interface does -- some code checks for it using "instanceof" and takes that as permission to serialize the object.
reply
    Bookmark Topic Watch Topic
  • New Topic