Practical side of the ability to define a class within an interface in Java?

前端 未结 11 1311
暖寄归人
暖寄归人 2020-12-30 06:32

What would be the practical side of the ability to define a class within an interface in Java:

interface IFoo
{
    class Bar
    {
        void foobar (         


        
11条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-30 07:25

    I guess you could define a class that is used as the return type or parameter type for methods within the interface. Doesn't seem particularly useful. You might as well just define the class separately. The only possible advantage is that it declares the class as "belonging" to the interface in some sense.

提交回复
热议问题