I know that an API is called a set of functions used to call something, and a library is a collection of classes, but what is actually API in package like java.lang
api is the set of classes that require for the development and library is part of api
for ex.suppose you need the communication api but you need only serial communication so the set of serial communication classes is library and the set of communication classes is api