A library is a collection of code built to perform common tasks. Library code tends to be relatively stable and bug free. Use of appropriate libraries can reduce the amount of code the need to be written. It will tend to reduce line of code counts for an application will increasing the rate at which functionality is delivered. In most cases, it is better to use a library routine than to write your own code.
An API (Application Programming Interface) is interface to some functionality which allows an application to access the available functionality. An API may be referred to as an Interface. API exist at many levels including system, library, framework, program, and application. APIs should be defined before the code implementing them is implemented.
APIs should be stable, although portions of the API can be deprecated for various reasons. The more broadly used the API the more difficult it is to change it. Most if not all of the Java 1.0 API is still available, although many methods are have been deprecated.
A Framework is a collection of APIs designed to make building of applications simpler. Frameworks provide implementations for reusable components. Good frameworks tend to be specialized in their application.
The Java Collections Framework is a collection of APIs to various types of objects that can be used to handle collections. It provides a hierarchy of APIs to various collections. The in the Java Collections Framework the SortedSet interface extends Set interface which in turn extends the Collection interface. These APIs are abstract interfaces, and the actual implementations have different names. The Collections Framework makes implementing collections simple, and simplifies changing implementations during development.
Frameworks can be built of smaller frameworks as is seen in the Java Spring Framework targeted at J2EE development. Spring consists of over a dozen frameworks, many of which can be used on their own or replaced by other frameworks.
Use of the appropriate libraries, APIs, and frameworks can simplify development. These components take care of the common issues, and allow the development team to focus on the application specific issues.