MediumJava for Beginners: Your First Step into Programming | by Samuacharya | Medium
Sitemap
Samuacharya

Samuacharya

Java for Beginners: Your First Step into Programming

2 min readJun 9, 2026

--

Introduction

Java is one of the most popular programming languages in the world. It is used to build web applications, mobile apps, desktop software, enterprise systems, and much more. If you are new to programming, Java is an excellent language to start with because it teaches important programming concepts and has a large community of developers.

In this tutorial, we will learn the basics of Java and write our first Java program.

What is Java?

Java is an object-oriented programming language developed by Sun Microsystems in 1995. One of Java’s biggest advantages is its platform independence. This means a Java program can run on different operating systems without modification.

Java follows the principle:

“Write Once, Run Anywhere”

Setting Up Java

Before writing Java code, you need:

  1. Java Development Kit (JDK)
  2. An IDE such as IntelliJ IDEA, Eclipse, or NetBeans

After installing Java, you can verify the installation by opening the command prompt and typing:

java -version

If Java is installed correctly, it will display the installed version.

Your First Java Program

Let’s create a simple program that prints a message on the screen.

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

Output

Hello, World!

Understanding the Code

public class HelloWorld

This creates a class named HelloWorld. In Java, every program is organized into classes.

public static void main(String[] args)

This is the main method. It is the entry point of every Java application. The program starts executing from this method.

System.out.println()

This statement displays text on the screen.

Variables in Java

Variables are used to store data.

Get Samuacharya’s stories in your inbox

Join Medium for free to get updates from this writer.

Example:

public class Variables {
public static void main(String[] args) {
int age = 21;
String name = "Samana";
        System.out.println(name);
System.out.println(age);
}
}

Common Data Types

  • int → Whole numbers
  • double → Decimal numbers
  • char → Single character
  • boolean → True or False
  • String → Text

Conditional Statements

Conditional statements allow programs to make decisions.

Example:

int age = 20;
if(age >= 18){
System.out.println("You are an adult.");
}else{
System.out.println("You are a minor.");
}

Loops in Java

Loops repeat a block of code multiple times.

Example:

for(int i = 1; i <= 5; i++){
System.out.println(i);
}

Output

1
2
3
4
5

Why Learn Java?

Java remains one of the most valuable programming languages because it is used in:

  • Android app development
  • Enterprise applications
  • Banking systems
  • Web development
  • Cloud applications

Learning Java also helps developers understand core programming concepts such as object-oriented programming, data structures, and algorithms.

Conclusion

Java is a powerful and beginner-friendly programming language that opens doors to many career opportunities in software development. By learning the basics such as variables, conditions, loops, and classes, you build a strong foundation for advanced programming concepts.

Start practicing small programs every day, and you will gradually become comfortable with Java development. Remember, programming is a skill that improves through consistent practice and problem-solving.

--

--