0

why classes in some java programs are implements an empty interface in java?

What is the usage?

interface E{
    
}
public class A implements E{
    public static void main(String[] args) {
        System.out.println("Something...");
    }
}
  • This is called Marker Interface, see the duplicated question for more info. – Pradeep Simha Nov 02 '21 at 06:37
  • Does this answer your question? [What is an empty interface used for](https://stackoverflow.com/questions/380665/what-is-an-empty-interface-used-for) – Burak Ozmen Nov 02 '21 at 06:37
  • 1
    Does this answer your question? [Marker Interfaces in Java?](https://stackoverflow.com/questions/25850328/marker-interfaces-in-java) – Pradeep Simha Nov 02 '21 at 06:38

2 Answers2

1

Basically it is used to logically divide the code and a good way to categorize code. It is more useful for developing API and in frameworks like Spring.

0

Also known as a Marker Interface:

http://en.wikipedia.org/wiki/Marker_interface_pattern