Skip to the content.

Fullstack > Java > 🚀 Introduction

What is Java?

Java is a popular programming language known for its simplicity, platform independence, and security. It is widely used for building applications in web development, mobile development, and enterprise software.

Why Learn Java?

How Java Works

Java follows the Write Once, Run Anywhere (WORA) principle. This means you write the code once, and it can run on different devices without modification.

  1. Write Code – Developers write Java code in .java files.
  2. Compile Code – The Java compiler (javac) converts the code into bytecode (.class files).
  3. Run Code – The Java Virtual Machine (JVM) executes the bytecode on different platforms.

Basic Structure of a Java Program

Every Java program has a main method, which is the starting point of execution.

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

Explanation:

Java Features

Java has several powerful features:

  1. Simple – Easy-to-understand syntax.
  2. Object-Oriented – Everything in Java is based on objects.
  3. Portable – Java programs can run on any OS.
  4. Secure – Java has built-in security mechanisms.
  5. Multithreading – Supports multiple tasks running simultaneously.

Java Data Types

Java has two main types of data:

  1. Primitive Data Typesint, char, boolean, float, etc.
  2. Non-Primitive Data TypesString, Arrays, Classes, etc.

Example of using different data types:

int number = 10;
String message = "Java is awesome!";
boolean isFun = true;
System.out.println(message);

Java Control Statements

Control statements help in decision-making and looping:

Example of an if statement:

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

Java OOP Concepts

Java follows Object-Oriented Programming (OOP), which includes:

  1. Classes and Objects – Blueprints for creating real-world entities.
  2. Inheritance – Allows one class to inherit from another.
  3. Polymorphism – Enables multiple methods with the same name.
  4. Encapsulation – Restricts access to data using access modifiers.
  5. Abstraction – Hides implementation details.

Java is a powerful language that is beginner-friendly and widely used in the industry. Understanding the basics of Java is the first step toward mastering programming.


← Java History and Evolution →

🔗 Related Topics: