java.io.Serializable
java.lang.Cloneable
java.util.RandomAccess
instanceof
operator or reflection.
Serializable
to be eligible for object serialization.Cloneable
, then Object.clone()
method will perform cloning, otherwise it throws CloneNotSupportedException
.// Marker Interface
interface Marker { }
// Class implementing Marker
class MyClass implements Marker
{
public void display()
{
System.out.println("Display method called");
}
}
public class MainApp
{
public static void main(String[] args)
{
MyClass obj = new MyClass();
if (obj instanceof Marker) {
obj.display();
} else {
System.out.println("Object not allowed");
}
}
}
Display method called
Annotations
(because annotations are more powerful and flexible).
Your feedback helps us grow! If there's anything we can fix or improve, please let us know.
Weโre here to make our tutorials better based on your thoughts and suggestions.