Tagging Interfaces in Java

前端 未结 8 2250
时光说笑
时光说笑 2021-01-02 06:26

What are tagging interfaces and what are they used for?

8条回答
  •  梦谈多话
    2021-01-02 06:50

    tagging interfaces are interfaces with no abstract methods inside , they are used to add a data type for the class which implements them and to be a parent interface for other interfaces ( especially with multiple inheritance in interfaces )

    public interface name {} 
    public interface john1 {} 
    public interface john2 {}
    public interface Demo extends john1 , john2 , name  {}
    

    ** when JVM sees the name interface , it will find out that the Demo will exert a specific cenario .

提交回复
热议问题