#Help with understand what the "Java API" is
28 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @stark skiff! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Please ping me when you're replying
an "interface" is a layer of operations that separate systems can use to interactwith each other. this layer defines the available operations without defining how to do those operations.
for example, a UI, a user interface, is used for a user to interact with a system, and the user doesn't have to see the code behind each button, they just see the button and probably text saying what that button does.
API is short for "application programming interface", it's used to let 2 programs or parts of programs interact with each other. for example, web apis define interfaces for programs to interact with websites.
apis also exist directly in code. libraries are also considered separate parts of a program, so libraries also define interfaces so other code can interact with the library. these are also apis, since they let different parts of a program interact with each other.
amongst the libraries are the standard libraries, which define basic operations in each language. for java, that's java.lang, java.util, etc. these are the "Java APIs", the apis that java defines for developers to use.
(last part was hastily written so might have some inaccuracies, if anyone spots any please do correct me)
Why call it API though? Why not just the Java library/inbuilt packages? (I come from a little bit of experience in C++. So it'll be helpful if you can point out the differences)
Is it the same thing? or are there any differences between libraries and APIs
"API" refers just to the interfaces without really worrying about the implementations. you can call them the java standard libraries just as well
but isn't that what libraries do as well? We only use the librarires and the features that it provides without having to worry about internal details
libraries define an api. you call the api at developing, only the language truly invokes the implementations at runtime
"library" as broader than api, it refers to the whole thing
think of it like the difference between .h and .c files
.h is the thing defining the interfaces
when you write code, you're only using the .h files
when you compile, the compiler obtains the .c files, and the runtime then uses the .c files
We write custom header (created by the user) with .h extension and the actual C programs with .c extension
(or .cpp i guess)
right, and what does #include use? just the headers. it only cares about the headers at that moment.
Yea I got what you're saying. In .h files, we define the class and provide the interface (without any implementation details) so that people can look at that .h file and figure out what functions they can use. We then define the functions/methods in the .cpp file. We only include the .h files in the main.cpp file and the linker will take care of finding that implementation from the .cpp file that we wrote earlier. This is how we abstract the implementation details from the class definition (while providing the interface)
the compiler and runtime care about the implementation, while the development environment doesn't
wait a sec. I think I kinda understood
let me explain what I understood and then tell me if I understood it correctly
Basically, all the .h files that we write the interfaces in, are included in what's called the "API" and the library consists of all the .h and .cpp files where the classes are declared in .h files and defined in .cpp files. In other words, all the interfaces to using inbuilt features come under the term "API" and the interfaces + implementation combined comes under the library. Is that right?
@shell python did I misunderstand something?
yeah that's right
alright got it. Thanks a lot!!
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.