Java / Interface
How to write your own marker interface?
We can create our own marker interface by creating an interface with no method. This marker interface has nothing to do with JVM, we add the special logic in market interface handler class by using instanceOf check.
interface IMarker{ } class MarkerImpl implements IMarker{ //do some task } class Main{ public static void main(String[] args){ MarkerImpl ob = new MarkerImpl(); if (ob instanceOf IMarker){ // do some task } } }
More Related questions...