August 2017
Beginner
298 pages
7h 26m
English
What does it mean for an interface to be accessible to a module in Java 9? Quite obviously, it means that you can use the interface type in the code in that module. However, an interface is quite meaningless without an implementation. Does this mean that when you export a public interface (as in LibApi), but not the implementation (LibApiImpl), the implementation is essentially useless outside the module? Not quite!
Consider we add a static method in the LibApi interface to create an instance of LibApiImpl. We'll also add a handy testMethod() to the interface for us to call from another module to verify if it works. Notice that while the createInstance method is creating a new instance of LibApiImpl ...
Read now
Unlock full access