JAVA program to print Multiplication Table

Today we shall program another simple and basic problem.In our childhood many of us find difficulty in learning the Multiplication tables.Now, we shall take revenge on them by writing the program.Let us consider that our program takes two values as inputs which are,one for the number of tables required starting from 1 and other for limit of the multiplication…i.e either upto 10 or 20.Here we need two for loops,one for iteration of table and other for the multiplication of the table.Let us know write the code for it.

import java.util.*;
class tables
  void calculation(int n,int limit)
      for(int i=1;i<=n;i++)
          System.out.println("***************Multiplication Table of " + i +" is ******************");
          for(int j=1;j<=limit;j++)
               System.out.println(i + " * " + j +" = "+(i*j));
class multiptables
  public static void main(String arg[])
       Scanner in = new Scanner(;
       System.out.println("Enter number of tables required starting from 1:");
       int n = in.nextInt();
       System.out.println("Enter limit of the tables to be multiplied:");
       int limit = in.nextInt();
       tables ob = new tables();

Explanation:In the main function we are getting the input from the user regarding number of tables and limit of the multiplication.Then we are invoking the function calculation by passing those inputs and printing the table.
The output of the above program is:
multiplication tables
You can download the source code.


About Anuroop D

Very enthusiastic about technology and likes to share my knowledge through blogging. Has Bachelor's in Information Technology and currently pursuing my PhD in Computer Science.
This entry was posted in Java and tagged , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s