What is the difference between Java API and Java methods

Are the methods and APIs basically the same in Java? If not, what makes them different?

+4
source share
3 answers

The API refers to the application programming interface that the rest of the world sees and can use.

The method can be part of the public interface or not. But the API is really a set of methods.

The most common API-related phenomenon in java will be an interface, which is really a public method declaration.

Another useful way to look at the API is to accept it as a contract. As an example, consider List . It tells you the signatures of the methods that you can use in the list, and in javadoc you see what the contract is (what you can expect and what you need for the list to behave as expected)

+5
source

An API consists of, among other artifacts, a set of types that include the methods, signature, and behavior of those methods that are specified in the API contract. So yes, an API and a method are two different things, like a paw, and a dog are two different things.

+2
source

To clarify Marcos, a very accurate, but somewhat brief answer: Specifically, you can come up with java interfaces and related javadoc as an API. For example, Collection defines an API that expands, for example. Set , while a HashSet is a concrete implementation of the Collection and Set APIs.

Greetings

+2
source

Source: https://habr.com/ru/post/1441491/


All Articles