What is the difference between a Java API and a library?

前端 未结 10 1536
面向向阳花
面向向阳花 2021-01-31 21:10

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

10条回答
  •  生来不讨喜
    2021-01-31 21:53

    API is a logical representation of non-empty collection of Java classes and interfaces (add annotations and enums).

    Library (being JAR Java library) is a unit of deployment of one, many or part of API.

    There is no one-to-one or many-to-one association between two in general since their concerns are orthogonal in nature: API is concerned with logic and functionality; library is concerned with deployment.

    Excellent resource that covers these relationships is Robert Martin Principles of OOD - look for last 6 package principles.

提交回复
热议问题