Block advanced interface

As in the class, I can do:

public final class Foo{}

which means that no classes can extend this class Foo... for example. Stringthe class is final, so a custom class cannot extend the class String.

How can I prevent doing the same with the interface?

If i do

public interface ISome{
    void fly();
}

I would like this

class A implements ISome {}

but block that

public interface IHouse extends ISome{
    void fly();
}

doing it

public final interface ISome{}

does not make sense ... and will result in a compilation error, for example:

Illegal modifier for the interface
+4
source share
1 answer

You can not.

Java , - : , interface , class.

, ++, , - , , , friend ship.

+4

Source: https://habr.com/ru/post/1652434/


All Articles