#Are the System supplied methods implemented with Java? If so, how could I make my own println?
1 messages · Page 1 of 1 (latest)
The System class is indeed written in Java, but if you looked more precisely in the sources, the Java code will end up calling native function
do you have an example?
No, not now, since im not on PC
the jdk is opensource, u can lookup the source code urself
here is the link:
example:
JDK main-line development https://openjdk.org/projects/jdk - openjdk/jdk
in some cases ull eventually end up at a method marked native
for example String#intern
the mechanism for this is called JNI
its javas way to call code implemented in C/C++
(u can ofc use that mechanism urself as well, making ur own native methods)
anyways, those methods are implemented in C/C++
u essentially just have to call System.loadLibrary("myLib.dll") somewhere
and then all methods inside there are available and linked against their native counterparts
these native methods are then typically the methods using platform specific code
so for example when the windows api has to be used
for example reading/writing a file is a platform specific operation
java offers it to u in a platform agnostic way but eventually it has to call the actual platform specific way to do it on ur current platform
@tribal gull
Your question has been closed due to inactivity.
If it was not resolved yet, click the button below to keep it
open, or feel free to create a new thread.
Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.
When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.
Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.
With enough info, someone knows the answer for sure 👍