This tutorial is part of the Java programming series. See Part 6 for more advanced topics, or start from the programming languages overview.
Setting Up the Java Environment
To write and run Java programs, you need the Java Development Kit (JDK). After installation, you can compile programs from the command line:
javac HelloWorld.java java HelloWorld
Your First Java Program
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Every Java program must have a main method. The System.out.println() method prints text to the console. Java is case-sensitive, so Main and main are different.
Key Concepts
- Class – The basic building block. Every Java file contains at least one class.
- Method – A block of code that performs a specific task.
- Variable – A named location in memory that stores a value.
Next: Java Data Types | Wrapper Classes