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

Time:11-02

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...");
    }
}

CodePudding user response:

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.

CodePudding user response:

Also known as a Marker Interface:

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

  • Related