Writing Your First Java Program

Java is a widely-used, object-oriented programming language known for its “write once, run anywhere” philosophy. Here’s how to write your first Java program:

Steps to Create “Hello, World!”

1. Prerequisites

  • Install JDK: Download and install from Oracle or OpenJDK.
  • Editor/IDE: Use tools like Visual Studio Code, IntelliJ IDEA, or Eclipse.

2. Write the Code

  1. Create a file named HelloWorld.java.
  2. Add this code:
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

3. Compile and Run

  • Compile: Open a terminal and run:
javac HelloWorld.java
  • Execute: Run the program:
java HelloWorld

Output:

Hello, World!

What’s Next?

Explore Java’s core features like variables, loops, and object-oriented programming. Happy coding!

Previous
Next

More Amazing Post

Get 15GB free hosting with Infinity Free

  • January 23, 2025

hosting is a compulsory thing for publish a website....

author-avatar
Posted By nazir

Programming Languages and Their Frameworks

  • January 20, 2025

Programming languages and frameworks go hand-in-hand to simplify and...

author-avatar
Posted By nazir

Uses of C#

  • January 20, 2025

C# (pronounced as “C-Sharp”) is a versatile and powerful...

author-avatar
Posted By nazir
Scroll to Top