- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program to multiply two matrices.
Following is the required program.
Example
public class Tester { public static void main(String args[]) { // matrix 1 int a[][] = { { 1, 3, 4 }, { 2, 4, 3 }, { 3, 4, 5 } }; // matrix 2 int b[][] = { { 1, 3, 4 }, { 2, 4, 3 }, { 1, 2, 4 } }; // result matrix int c[][] = new int[3][3]; // 3 rows and 3 columns // multiply and print matrix for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { c[i][j] = 0; for (int k = 0; k < 3; k++) { c[i][j] += a[i][k] * b[k][j]; } System.out.print(c[i][j] + " "); } System.out.println(); } } }
Output
11 23 29 13 28 32 16 35 44
- Related Articles
- C# program to multiply two matrices
- Python program to multiply two matrices
- Program to multiply two matrices in C++
- Swift Program to Multiply two Matrices Using Multi-dimensional Arrays
- C++ Program to Multiply two Matrices by Passing Matrix to Function
- How to Multiply Two Matrices using Python?
- Java program to add two matrices.
- Java program to subtract two matrices.
- Golang Program to Multiply two Matrices by Passing Matrix to a Function
- Swift Program to Multiply two Matrices by Passing Matrix to a Function
- How to multiply two matrices by elements in R?
- How to multiply two matrices using pointers in C?
- How to write Java program to add two matrices
- How to multiply corresponding values from two matrices in R?
- Java Program to Multiply Two Floating-Point Numbers

Advertisements