Are methods and APIs, basically the same in Java? If no, what makes them different?
API refers to Application Programming Interface, what the rest of the world see and can use.
Method can be part of the public interface or not. But API is really set of methods.
The most common thing related to APIs in java would be Interface which is really set of public method declarations.
Another useful way how to look on API is to take it as contract. Lets take a List interface as an example. It tells you method signatures you can use in a List and in javadoc you see what is the contract (what you can expect and what you need to ensure so the List behaves as expected)
API consists of, among other artifacts, a set of types, which include methods, the signature and behavior of those methods specified by the API contract. So yes, API and method are two different things, just like a paw and a dog are different things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With