Your First Program and Output
Your first Java program: the Main class, the main method and System.out.println.
Java is a strict and verbose language: even the smallest program is written as a class with a main method. In return, that strictness teaches discipline, and the Java virtual machine is fast.
Important specifically for this site: the public class must be named Main — otherwise the judge will not be able to compile your solution.
Press "Run" and look at the result.
Java
Your first Java program
Let's break down the mandatory boilerplate:
• public class Main — the class declaration; all Java code lives inside classes;
• public static void main(String[] args) — the entry point: execution starts from this method;
• System.out.println(...) — prints a line followed by a newline (print without ln — no newline);
• every statement ends with a semicolon.
Try changing the text inside the quotes and run it again.
Java
println can print text and calculations
Note the parentheses around (2 + 2): for strings the + operator means concatenation, so without parentheses "..." + 2 + 2 would print "22".
Task: print three lines — your name, your city and the result of 7 * 6. Then mark the lesson as completed.