Learn Java_ Hello World Cheatsheet _ Codecademy
Learn Java_ Hello World Cheatsheet _ Codecademy
Hello World
Print Line
Comments
Comments are bits of text that are ignored by the // I am a single line comment!
compiler. They are used to increase the readability of a
program.
Single line comments are created by using // . /*
Multi-line comments are created by starting with And I am a
/* and ending with */ .
multi-line comment!
*/
Compiling Java
In Java, when we compile a program, each individual class # Compile the class file:
is converted into a .class file, which is known as byte
javac hello.java
code.
The JVM (Java virtual machine) is used to run the byte
code. # Execute the compiled file:
java hello
https://www.codecademy.com/learn/learn-java/modules/learn-java-hello-world/cheatsheet 1/3
12/21/24, 9:45 AM Learn Java: Hello World Cheatsheet | Codecademy
Whitespace
System.out.println("Another statement");
// Output:
// Example of a statement
// Another statement
Statements
In Java, a statement is a line of code that executes a task System.out.println("Java Programming ☕️");
and is terminated with a ; .
main() Method
https://www.codecademy.com/learn/learn-java/modules/learn-java-hello-world/cheatsheet 2/3
12/21/24, 9:45 AM Learn Java: Hello World Cheatsheet | Codecademy
Classes
Print Share
https://www.codecademy.com/learn/learn-java/modules/learn-java-hello-world/cheatsheet 3/3