> For the complete documentation index, see [llms.txt](https://codewithmeiy.gitbook.io/core-java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codewithmeiy.gitbook.io/core-java/overview-of-java/hello-world.md).

# Hello World!

Certainly! The "Hello, World!" program is often the first program you write when learning a new programming language. Here's how you can create a simple "Hello, World!" program in Java:

```java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
```

Explanation:

* `public class HelloWorld`: This declares a class named `HelloWorld`. In Java, the name of the class must match the name of the file (excluding the `.java` extension). In this case, the file should be named `HelloWorld.java`.
* `public static void main(String[] args)`: This is the main method. It is the entry point of the program, and it's where the program execution begins. It takes an array of strings (`args`) as input, which can be used to pass command-line arguments to the program.
* `System.out.println("Hello, World!");`: This line of code prints "Hello, World!" to the console. The `System.out.println()` method is used to display text, and it automatically adds a newline character after the text, so each call to `println` results in a new line.

To run this program:

1. Save the code above into a file named `HelloWorld.java`
2. Open a command prompt or terminal window.
3. Navigate to the directory where you saved the `HelloWorld.java` file.
4. Compile the Java source code by running: `javac HelloWorld.java`
5. After a successful compilation, run the program with the following command: `java HelloWorld`
6. You should see the output "Hello, World!" displayed in the terminal.

That's it! You've created and run a simple "Hello, World!" program in Java.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://codewithmeiy.gitbook.io/core-java/overview-of-java/hello-world.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
