Java Programming Course for Beginners

Master Java step by step with beginner-friendly explanations, real-world examples, and strong object-oriented programming foundations. This course is designed for absolute beginners who want to start coding in Java and build real applications.

1. Introduction to Java

Java is a high-level, object-oriented programming language developed by Sun Microsystems (now owned by Oracle). It is one of the most popular programming languages in the world and is widely used for building web applications, Android apps, desktop software, enterprise systems, and backend servers.

Java follows the principle "Write Once, Run Anywhere" because Java code runs on the Java Virtual Machine (JVM). This means Java programs can run on any device that has a JVM installed, regardless of the operating system.

Java is known for being secure, robust, portable, and easy to maintain, which makes it a top choice for large-scale software development.

2. Basic Structure of a Java Program

Every Java program must have at least one class and one main method. The main method is the starting point of program execution.

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

Explanation:

public class Main → Defines a class named Main.
public static void main(String[] args) → Entry point of the program.
System.out.println() → Prints output to the screen.

3. Variables in Java

Variables are containers used to store data values. Each variable must have a data type that defines what type of data it can hold.

int age = 20; double height = 5.9; char grade = 'A'; boolean passed = true;

Java is a strongly typed language, meaning you must declare the type of data a variable will store before using it.

4. Data Types in Java

Java has two main categories of data types:

1. Primitive Data Types → int, double, float, char, boolean, byte, short, long
2. Non-Primitive Data Types → Strings, Arrays, Classes, Interfaces

Primitive types store simple values, while non-primitive types store references to objects.

5. Taking User Input

Java allows user input using the Scanner class from the java.util package.

import java.util.Scanner; Scanner sc = new Scanner(System.in); int num = sc.nextInt();

This lets the program read values typed by the user at runtime.

6. Operators in Java

Operators are used to perform operations on variables and values.

Types of operators:

Arithmetic (+, -, *, /, %)
Relational (==, !=, >, <, >=, <=)
Logical (&&, ||, !)
Assignment (=, +=, -=)

int a = 10, b = 5; System.out.println(a + b); System.out.println(a > b);

7. Conditional Statements

Conditional statements help the program make decisions based on conditions.

int age = 18; if(age >= 18){ System.out.println("Adult"); }else{ System.out.println("Minor"); }

Java also provides switch statements for multiple conditions.

8. Loops in Java

Loops are used to repeat a block of code multiple times.

Types of loops: for loop, while loop, do-while loop

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

9. Methods in Java

Methods are blocks of code that perform specific tasks and help make programs modular and reusable.

static int add(int a, int b){ return a + b; }

Methods reduce code repetition and improve readability.

10. Arrays in Java

An array stores multiple values of the same data type in a single variable.

int[] numbers = {1,2,3,4,5};

Arrays are useful when working with lists of data like marks, prices, or names.

11. Strings in Java

A String is used to store text. Strings in Java are objects of the String class.

String name = "Kafe"; System.out.println(name);

Java provides many built-in string methods like length(), toUpperCase(), and substring().

12. Object-Oriented Programming (OOP)

Java is fully object-oriented. OOP helps organize code into reusable structures.

Four pillars of OOP:
Encapsulation → Wrapping data and methods together
Inheritance → One class acquiring properties of another
Polymorphism → One action, many forms
Abstraction → Hiding internal details

13. Classes & Objects

A class is a blueprint for creating objects. Objects represent real-world entities.

class Car { String brand; int year; }

Here, Car is a class and brand/year are its properties.