I am new to java.My friend asked me this question today And i am looking for an answer to it. How to make the number of class files in a package, constant? i.e., even though one can access that package,they should not be able to add any new class to the exisiting package.
You want sealed packages. Once sealed, all classes from a package must come from the same JAR file. It basically boils down to adding the package to the manifest:
Name: myCompany/myPackage/
Sealed: true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With