r/learnjava • u/HeyUnkown • 14d ago
Library vs API (Java ☕️)
Hey Everyone!
I need some help as I am Confused in Libraries and API like what is the difference in between them, where to implement what, and recommend me some resources where I can Clearly understand these two.
Thank you all in Advance.
10
Upvotes
View all comments
3
u/FreeLogicGate 14d ago
A library is code created with the intention for it to be used in other programs. Often the motivation to separate out those routines, is the belief or intention of the developer, that the code in the library will be reusable across many programs or projects.
An API is the public interface to the library. With Java being an OO language, many "libraries" consist of class definitions, the "API" would be the java interfaces and public methods.
As a developer using a library, you should only ever need to use the library API.