Java Beginner Edition

Writing Your First Java Program

Hello, World!

Start by creating a new Java class in your IDE. Name it "HelloWorld" and enter the following code:

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

Save your file and run the program. You should see the output "Hello, World!" in your IDE's console.

Hello, World!

Basic Java Concepts

As you continue learning Java, you'll encounter several key concepts, such as:

Concept Description Example
Variables and data types Storage of data in different formats int, String, boolean
Operators and expressions Perform calculations and comparisons +, -, *, /, %
Control structures Loops and conditionals for controlling the flow of a program if, for, while
Arrays and Collections Store multiple values in a single variable int[], ArrayList
Classes and objects Define custom data types and create instances of them public class MyClass
Methods and inheritance Encapsulate functionality and extend classes public void myMethod()