Basic program of JAVA.
JAVA
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
```
Explanation:
- public class HelloWorld:
This defines a class named `HelloWorld`. In Java, every application must have at least one class.
- **public static void main(String[] args)**:
This is the main method where the program execution begins.
- `public`: The method can be called from anywhere.
- `static`: It can be called without creating an instance of the class.
- `void`: It does not return any value.
- `String[] args`: This allows the program to accept command-line arguments.
- **System.out.println("Hello, World!");**: This line prints "Hello, World!" to the console.
How to Run the Program:
1. Save the code in a file named `HelloWorld.java`.
2. Open a terminal (or command prompt) and navigate to the directory where the file is saved.
3. Compile the program using the command:
```
javac HelloWorld.java
```
4. Run the compiled program with:
```
java HelloWorld
```
You should see the output:
```
HELLO WORLD
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOPIC = JAVA.
2. WHAT IS JAVA ?