I was wondering that why in Java we have packages not libraries. I had a lot of discussion with my friends over this issue. And they were telling that we can consider packages as libraries. Since C++ already had the concept of libraries then why there was need to create a new name called Packages.
P.S.: Is it really worth to correct someone if he calls packages libraries.
A package is a Java construct used to organise classes. They provide:
That's it; what implementers do with this organizational feature is up to them.
A library is another organizational concept. However, the intention of a library is to provide a a well-defined interface to the outside world and an internal implementation to execute as needed.
Both are organizational ideas and libraries are often made up of packages (if implemented in Java). However, they have different intent and so it is sensible to give them different names. Often, a small library will fit in a single package, so using one to mean the other is probably not confusing. However, they are not the same.
Packages are namespaces. There are uncountable "Util" classes, but you can uniquely identify them because of their fully qualified name that is the package + class name.
A library is a set of classes that concur to provide a feature/functionality.
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