First Java Program by ocec

First Java Program :
In this section, we will learn how to write the simple program of Java. We can write a simple hello Java program easily after installing the JDK.
To create a simple Java program, you need to create a class that contains the main method. Let's understand the requirement first.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Now, let me explain what each part of this code does:
1. `public class HelloWorld { ... }`: This line defines a class named `HelloWorld`. In Java, every program must have at least one class, and the name of the file containing the code must match the name of the public class.
2. `public static void main(String[] args) { ... }`: This line defines a method named `main`. In Java, the `main` method is the entry point for any program. It's where the program starts executing. The `public`, `static`, and `void` keywords have specific meanings:
- `public`: This keyword indicates that the method can be called from anywhere.
- `static`: This keyword indicates that the method belongs to the class itself, rather than to instances of the class.
- `void`: This keyword indicates that the method does not return any value.
3. `System.out.println("Hello, World!");`: This line uses the `System.out.println()` method to print the string `"Hello, World!"` to the console. The `System.out` object represents the standard output stream, typically the console or terminal where you see text output. The `println()` method is used to print a string followed by a newline character, so each call to `println()` starts on a new line.
When you run this program, it will output:
Hello, World!
This simple program demonstrates the basic structure of a Java program and how to output text to the console.

Sandipan Kr Bag
I'm a dedicated full-stack developer, entrepreneur, and the proud owner of ocec.org.in , hailing from the vibrant country of India. My passion lies in creating informative tutorials and sharing valuable tips that empower fellow artisans in their journey. With a deep-rooted love for technology, I've been an ardent enthusiast of PHP, Laravel, Angular, Vue, Node, JavaScript, jQuery, Codeigniter, and Bootstrap from their earliest days. My philosophy revolves around the values of hard work and unwavering consistency, driving me to continuously explore, create, and share my knowledge with the tech community.
* Hire MeRelated Posts

জাভাস্ক্রিপ্ট কি? এটি কেন ব্যবহার করা হয় ?

জাভাস্ক্রিপ্ট লেখার পদ্ধতি
Step-by-Step Guide a Dynamic Image Slider with HTML, CSS, and JavaScript
Search
Latest Posts
Using AOS (Animate On Scroll) in React with Tailwind CSS
1 month ago

WebkitSpeechRecognition API
2 months ago

GitHub Understanding Common Prefixes in Conventional Commits
2 months ago
Subscribe to Our Newsletter
Get the latest updates straight to your inbox.