Objectives
- Understand the Java compilation and execution process
- Write and run a basic Java program
- Compare Java and C++ at a high level
Java Program Structure
Here's a simple "Hello, World!" program in Java:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
Java vs. C++: Key Differences
Java
- Runs on JVM
- No pointers
- Garbage collection
- No header files
- Platform-independent bytecode
C++
- Compiled to native code
- Uses pointers
- Manual memory management
- Requires header files
- Platform-specific binaries
Exercise
Write your own Java class that prints your name and favorite programming language.
Next Steps
- Try compiling and running your Java program
- Install JDK and an IDE (e.g., IntelliJ, Eclipse, or VS Code)
- Get ready for Java classes and objects in Module 2