Java For Beginners

JAVA BEGINNERS (Learn Java in 7 days)

In this blog we are going to learn about Java from the basic to the advanced level. Before we start, we want to let you know about the History of Programming which will add more fun to the topic. Let’s get started with Java.

Java Introduction

Java is a very well known and most used programming language, which was created in 1995. 

Java is owned by Oracle and it is everywhere — literally billions of devices run Java. As of recent estimates, Java runs on over 3 billion devices worldwide

It is used for:

  • Mobile applications (specially Android apps)
  • Desktop applications
  • Web applications
  • Web servers and application servers
  • Games
  • Database connection
  • Embedded Systems
  • Cloud Platforms
  • Banking & Finance

Why do so many devices use Java?

There are many reasons this devices use Java for their work such as:

  • “Write Once, Run Anywhere” — Java runs on nearly any system with a Java Virtual Machine (JVM).
  • One of the most well known programming languages.
  • It has very good Stability.
  • It is very secure and fast performance — all attractive for long-term enterprise use.
  • One of the biggest strengths of this language is Object-Oriented Programming (OOP).

What does Object-Oriented mean?

Object-Oriented Programming is a style of programming where software is built using objects — real-world entities like cars, bank accounts, or employees. These objects combine:

  • Attributes (Data) — Like color, name, or balance
  • Methods (Behaviors) — Like drive(), deposit(), or withdraw()

Core Principles of OOP in Java 

Java follows 4 main pillars of OOP:

Principle

Meaning

Example

Encapsulation

Protecting data by keeping it private and exposing only necessary methods

private int balance; public void deposit()

Inheritance

One class can inherit properties and methods from another class

class Car extends Vehicle

Polymorphism

One method behaves differently depending on the object using it

draw() can draw a Circle or a Square

Abstraction

Hiding complex details and showing only the essential parts

interface Animal { void makeSound(); }

Example: Object-Oriented Class in Java

Here’s a simple Java class demonstrating these principles:

public class Car {

    private String brand;

    private int speed;

    public Car(String brand) {

        this.brand = brand;

        this.speed = 0;

    }

    public void accelerate(int increase) {

        speed += increase;

    }

    public void displayInfo() {

        System.out.println(brand + ” is running at ” + speed + ” km/h”);

    }

}

Explanation:

  • Encapsulation: brand and speed are private — only accessible through public methods.
  • Real-world object: The Car object has data (brand, speed) and behaviors (accelerate(), displayInfo()).

Why OOP Makes Java Powerful

  • Modular and Manageable Code: You can split code into small, reusable objects.
  • Real-world modeling: It’s easier to map real-world scenarios into objects and relationships.
  •  Reusability: Objects can be reused across programs, reducing duplicate code.
  •  Scalability: Adding new features becomes easier when using OOP structure.
  •  

“” Java’s object-oriented nature is one of its biggest advantages, especially in large projects where maintainability and scalability matter. Whether you’re a beginner or an experienced developer, understanding OOP in Java is a must-have skill.””

How to install Java to your Desktop?

First we need to check whether your system has already installed Java or not, for that you need to go to your system directory. For going into your system directory or CMD press Windows key + R. Then type CMD and then click on Ok. 

Once you will click on that you will get a option like this: 

You need to enter a Command “Java -version”, once you enter this command then press enter. If Java has already been installed to your system you will get the version info like this:

In case Java has not been installed to your system you can click here oracle.com and download it for free. 

You can also click on the video below to know how to download it and use it with VS Code editor. 

EMBEDDED VIDEO

Run your first code in Java.

Let’s assume that you have successfully installed Java into your system and now it’s the time to Run your first code in your code editor (VS CODE), you can also use any code editor like such as IntelliJ IDEA, Netbeans or Eclipse, which are particularly useful when managing large collections of Java files. You can also use our compiler “link”.

Example code:- 

public class HelloWorld {

    public static void main(String[] args) {

        System.out.println(“Hello, World!”);

    }

}

Now you guys must be wondering what this above code is for? So, not to worry, let me break it down for you. 

Code Explanation:- 

First of all we need to declare a class as written over there “HelloWorld”. Your program code goes here (inside the class). The name of the file which you will put will be considered as the class name and every code you will write will come under this class. 

Java is a pure object-oriented language (except for some primitives like int, float, etc.), so all your code must live inside a class

Let’s come to the next line of the code which is “public static void main(String[] args)” .

This is super important because this is the entry point for every Java program — without this, your program won’t run.

Breaking it Down :-  

Keyword

Meaning

public

This makes the main() method accessible from anywhere (needed because Java runtime needs to find and run it).

static

Means this method belongs to the class itself (not to an object of the class). This is necessary because Java starts the program without creating an object.

void

Means this method doesn’t return any value. It just runs and exits.

main

The exact name Java looks for to start the program. If you change it (like to start()), the program won’t run.

String[] args

This is an array of strings, used to accept command-line arguments (inputs from the terminal when running the program). This part can be empty if no arguments are needed, but you must write it this way for compatibility.

Now the final line is System.output.println(“Hello World”); which is a command to the system to print the text quoted under it in the next line. 

This is the command in Java that prints text to the console — basically, it displays output when you run your program. 

Java
Share your love

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *