1import java.util.Scanner;
2public class MultiplicationTablesInJava
3{
4 public static void main(String[] args)
5 {
6 System.out.println("Please enter an integer to print tables : ");
7 Scanner sc = new Scanner(System.in);
8 int number = sc.nextInt();
9 System.out.println("Multiplication table of " + number + " is : ");
10 for(int a = 1; a <= 10; a++)
11 {
12 System.out.println(number + " * " + a + " = " + number * a);
13 }
14 sc.close();
15 }
16}
1public static String multiTable(int num) {
2 StringBuilder sb = new StringBuilder();
3
4 for (int i = 1; i <= 10; i++) {
5 int result = i * num;
6 sb.append(i + " * " + num + " = " + result + "\n");
7 }
8 return sb.toString().trim();
9 }