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

前端 未结 10 1540
面向向阳花
面向向阳花 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:52

    Straight from Wikipedia:

    In computer science, an application programming interface (API) is an interface that defines the ways by which an application program may request services from libraries

    Java contains many libraries in those packages (Swing, etc.), and the API is the interface by which we request services (perform actions, etc.).

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-31 22:01

    Api is a list of all classes that are part of the JDK .it all includes all Java Packages,classes and interface ,along with their method,field, and constructor.

    A java package is a technique for organizing java classes into namespace similar to the modules of Modular,provide modular programming in java packages can be in compresses files called JAR files,allowing classes to be downloaded fast as groups rather than individually.

    0 讨论(0)
  • 2021-01-31 22:03

    In object-oriented programming , a class library is a collection of prewritten class es or coded templates, any of which can be specified and used by a programmer when developing an application program. you could use a library in a variety of projects. A framework is a collection of patterns and libraries to help with building an application. An API is an interface for other programs to interact with your program without having direct access.

    0 讨论(0)
提交回复
热议问题