In this tutorial, we will discuss Java code to multiplication table using Array
We can display the multiplication table in the Java language in various ways. In this tutorial, we will learn how to display the multiplication table using the two-dimensional array in Java programming language
Here, we can print 10 * 10 multiplication table using two dimension array with nested for loop
Program 1
public class MulTableInJava{ public static void main (String args[]){ int MulTable[][]=new int[10][10]; int row=1,column=1; for(int i=0; i<MulTable.length; i++){ for(int j=0; j<MulTable[i].length; j++){ MulTable[i][j]=row*column; column=column+1; } row=row+1; column=1; } for(int i=0; i<MulTable.length; i++){ for(int j=0; j<MulTable[i].length; j++){ System.out.print(" "+MulTable[i][j]+"\t| "); } System.out.print("\n"); } } }
When the above code is executed, it produces the following results
Here, we can print 10 * 10 multiplication table using the two-dimensional array with nested while loop
Program 2
public class MulTable2{ public static void main (String args[]){ int MulTable[][]=new int[10][10]; int row=1,column=1; int i=0; while(i<MulTable.length){ int j=0; while(j<MulTable[i].length){ MulTable[i][j]=row*column; column=column+1; j++; } row=row+1; column=1; i++; } i=0; while(i<MulTable.length){ int j=0; while( j<MulTable[i].length){ System.out.print(" "+MulTable[i][j]+"\t| "); j++; } System.out.print("\n"); i++; } } }
When the above code is executed, it produces the following results
Suggested for you
Two dimension array in Java language
PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…
PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…
5 methods to add two numbers in Java In this tutorial, we will discuss the…
Python full Pyramid star pattern program In this tutorial, we will discuss the concept of…
Write a function or method to convert C into F -Entered by the user In…
How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…
View Comments
Nice blog and content, I really excited, thanks for share!
What a great educative blog, it really helps me out for finding solutions to my issue with Array.