What\'s the reason of making top-level class non-public in Java?
Let\'s say we have Foo.java
, there could be
class Foo {
}
Here is an example. No one needs to know about existence of our ConcreteDocument.
DocumentIF.java
public interface DocumentIF {
}
ConcreteDocument.java
class ConcreteDocument implements DocumentIF {
}
DocumentFactory.java
public class DocumentFactory {
public DocumentIF createDocument() {
return new ConcreteDocument();
}
}