Class
A Java program is a sequence of statements that express an executable action. The statements are organized in methods, and methods are organized in classes. One or more classes are stored in .java
files. They can be compiled (transformed from the Java language into a bytecode) by the javac
Java compiler and stored in .class
files. Each .class
file contains one compiled class only and can be executed by JVM.
A java
command starts JVM and tells it which class is the main
one, the class that has the method called main()
. The main
method has a particular declaration – it has to be public static
, must return void
, has the name main
, and accepts a single parameter of an array of a String
type.
JVM loads the main class into memory, finds the main()
method, and starts executing it, statement by statement. The java
command can also pass parameters (arguments) that the main()
method receives as an array of String
values. If JVM encounters a statement that requires the execution...