Back to Modules

Java Tutorial

Master Java programming with our comprehensive tutorial. Learn object-oriented programming through examples and hands-on practice.

Full Playlist (Watch on Youtube)

Introduction to Java

Java is a class-based, object-oriented programming language designed to be platform-independent and secure.

Examples:

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

A simple Hello World program in Java

Java Basics

Learn fundamental Java concepts including variables, data types, and basic operations.

Examples:

// Data types and variables
int number = 42;
double pi = 3.14159;
char grade = 'A';
boolean isValid = true;
String name = "John";

Common data types and variable declarations in Java

// Basic array declaration
int[] numbers = {1, 2, 3, 4, 5};
String[] names = new String[3];

// ArrayList example
ArrayList<String> list = new ArrayList<>();
list.add("Java");
list.add("Programming");

Arrays and ArrayList examples

Object-Oriented Programming

Java is built around OOP principles: encapsulation, inheritance, polymorphism, and abstraction.

Examples:

public class Student {
    private String name;
    private int age;
    
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
    
    public void study() {
        System.out.println(name + " is studying.");
    }
}

A simple class demonstrating OOP concepts

Control Flow and Loops

Learn how to control program flow using conditional statements and loops in Java.

Examples:

// If-else statement
    if (score >= 90) {
            grade = 'A';
    } else if (score >= 80) {
            grade = 'B';
    } else {
            grade = 'C';
    }

    // For loop
    for (int i = 0; i < 5; i++) {
            System.out.println(i);
    }

    // While loop
    int count = 0;
    while (count < 3) {
            System.out.println("Count: " + count);
            count++;
    }

Examples of control flow statements and loops in Java