Kamil Hlubek wrote:I am asking you that, because this is one subject of Java 8, but I can not find a good guide to it and I want to understand it completely and not try it only out with a chance that something of my explanation could be false.
it would be nice to see which code attempts you have already tried. That's always the best approach to learn. And if you are in doubt, you can of course always post the code snippet and ask your questions in these forums.
You know from classes that
super can be used to invoke the overridden method of the parent class. I would expect similar behavior with the instance methods of interfaces, so only the default interface methods not the static interface methods. And the syntax is also a little bit different from what you are used to with classes
Output:
Printed in Super
Printed in Sub
Printed in SuperClass
Printed in SubClass
Now static interface methods can be invoked similarly to class/static methods (using the interface name). And you are also not required to follow the class/interface hierarchy
Output:
Printed in Super
Printed in SuperClass
Printed in Sub
Printed in SubClass
Hope it helps!
Kind regards,
Roel
PS. The above only applies to Java 8. In Java 7 you can only have abstract interface methods, so the above code snippets won't compile.