public class HelloWorld
public static void main(String[] args)
[Link]("Hello, World!");
1. Class Declaration
public class HelloWorld
class: Keyword to define a class (the basic building block of Java
programs).
HelloWorld: The name of the class (must match the filename →
[Link]).
public: Access modifier meaning this class can be accessed from
anywhere.
👉 In Java, everything must be inside a class.
2. Curly Braces { }
// code inside
Curly braces define a block of code.
The opening { starts the block, and the closing } ends it.
Every class and every method must have its own block.
3. Main Method
public static void main(String[] args)
This is the entry point of every Java program.
The program always starts execution here.
Breaking it down:
o public → accessible everywhere.
o static → runs without creating an object.
o void → returns nothing.
o main → the special method name where execution begins.
o (String[] args) → allows input from command line (not always
used by beginners).
4. Statements
[Link]("Hello, World!");
[Link] → Prints text to the screen and moves to a new
line.
; → Every Java statement must end with a semicolon.