Chamoda De silva
Chamoda De silva

Reputation: 63

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

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

Upvotes: 0

Views: 64

Answers (2)

AndreaCavallo.class
AndreaCavallo.class

Reputation: 377

Also known as a Marker Interface:

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

Upvotes: 0

Danish Alam
Danish Alam

Reputation: 34

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.

Upvotes: 1

Related Questions