+ 1
What does JVM do? (Simple words)
10 Respuestas
+ 2
its acts as an interpreter when you compile a java program it turns your code into Bytecode a special language read by the JVM. when you run your program the JVM translates that bytecode into machine code that the computer can understand, the computer does not understand Bytecode and without the JVM a java program would not be able to run. think of it like this, i speak english and say you speak russian i however do not, so we need a third person an interpreter who conveys to you what i am saying in your natural language therefore its not necessary that i learn your language or vice versa.
+ 2
Nikhil Singh C compilers translate the C code directly to machine language thats why if you want to run it on a different OS you have to use a specific Compiler for it, an analogy for this is i write you a note and then someone rewrites the whole note in your language and then it sends.
+ 2
Robert Atkins Excellent explanation! 👌
+ 2
Chriptus13 thank you :)
+ 2
A Java virtual machine (JVM), an implementation of the Java Virtual Machine Specification, interprets compiled Java binary code (called bytecode) for a computer's processor (or "hardware platform") so that it can perform a Java program's instructions.
+ 1
Understood.
But C doesn't have any JVM of its own
How does computer understand our codes then?
+ 1
Robert Atkins thanks!
+ 1
Robert Atkins Can u also explain why we declare static in main function?
(simple words)
0
it creates a virtual machine using java
0
Nikhil Singh static means that the class owns it and uses it when a program runs it calls the main() method of said program, instances of an object occur only within a program therefore its impossible to create an object of the main program and then run its main() method.
you can run a static method like so
ClassName.methodName()
whereas an instance method must be ran
CreatedObject.methodName()
sorry if that doesnt help you any, if you dont understand what static means in java a quick search will help you understand better what i am saying.