Syntax
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
Java is a language released by Sun (now Oracle) in 1995. It's used to write servers, Android apps, Minecraft and banking systems. Its motto is "write once, run anywhere".
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
- all code lives inside a class;
public class Mainmust be in a file calledMain.java— the file name = the class name; mainis the entry point, and its signature is alwayspublic static void main(String[] args);- statements end with
;, blocks go in{ }; case matters:Mainandmainare different names; - classes are named in
PascalCase, methods and variables incamelCase.
What's under the hood. javac compiles Main.java not into machine code but into bytecode — the file Main.class.
It's run by the JVM (the Java Virtual Machine): at first it interprets it, and it turns the "hot" spots into
machine code on the fly (JIT). That's why one .class file works on Windows, Linux and macOS — each system has its own JVM.
Here Java is compiled and run on the server, in a sandbox.
Task. Print Hello World.
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.