Java Program to Print Multiplication Table

Printing a multiplication table is one of the most common beginner programs in Java. It helps learners understand loops and repetitive execution.

In this tutorial, we will create a Java program to print the multiplication table of a given number.

By the end of this guide, you will understand how loops can be used for repeated calculations in Java.

Concept Overview

A multiplication table is generated by multiplying a number with a sequence of integers (usually 1 to 10).

For example, 5 × 1 = 5, 5 × 2 = 10, and so on.

Program

Java
import java.util.Scanner;

public class MultiplicationTable {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter a number: ");
        int num = sc.nextInt();

        for (int i = 1; i <= 10; i++) {
            System.out.println(num + " x " + i + " = " + (num * i));
        }
    }
}

Output

TEXT
Enter a number: 5
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
... up to 5 x 10 = 50

Detailed Explanation

The program starts by taking input from the user using the Scanner class.

A for loop runs from 1 to 10 to generate the multiplication table.

Inside the loop, the number is multiplied by the loop counter i.

Each result is printed in a formatted way.

Example Walkthrough

Let us consider input 5.

The program prints: 5 × 1, 5 × 2, ... up to 5 × 10.

Applications

Multiplication tables are used in education software, calculators, and learning applications.

Advantages of This Approach

This program helps beginners understand loops and repetitive operations.

It demonstrates how structured output can be generated.

Limitations

The program is fixed to printing only up to 10 multiples.

Improvements You Can Make

You can allow the user to choose the range of the table.

You can also format the output more neatly or store it in an array.

This Java program strengthens understanding of loops and arithmetic operations in a structured way.