That is a common misinterpretation of the intention of an interface. An interface is intended to have classes which implement it and those classes are intended to be instantiated and used as objects. That class is also a Path, so you declare the return type as Path.Search for “program to the interface, not the implementation” for more information.Richard Legué wrote:. . . an interface (not meant to be instantiated and used as an object) . . .
Richard Legué wrote:an interface (not meant to be instantiated and used as an object)
It seems to me that Path could be - or should be - a regular class, while it is not using it's interface functionality of offering generic functionalities for inheritance and polymorphism.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
It is possible that Paths has a private nested class which implements Path; that will never be visible in the public API. You can find out quite a bit simply from the code I showed you to find the class name. I expect it will differ with the implementation. The class might also be in a separate package whose documentation is omitted from the published API. That allows the implementer to change the actual class without having to give notice.Richard Legué wrote:. . . the (to me invisible) class was that implemented the Path interface . . . .
Stephan van Hulst wrote:For instance, you could make an implementation for Unix systems that doesn't allow backslashes as separators, or something completely different (for instance, there are file systems that don't have a hierarchical folder structure at all).
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie wrote:It is possible that Paths has a private nested class which implements Path; that will never be visible in the public API. You can find out quite a bit simply from the code I showed you to find the class name. I expect it will differ with the implementation. The class might also be in a separate package whose documentation is omitted from the published API. That allows the implementer to change the actual class without having to give notice.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Do Re Mi Fa So La Tiny Ad
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|