
Explanation of Solution
Method “matrixAdd()” to return the added values of two dimensional array:
//Definition of class Test
public class Test
{
//Definition of main class
public static void main(String[] args)
{
//Create an two dimensional array
int a[][] = { { 10, 20 },
{ 15, 25}};
int b[][] = { { 25, 35 },
{ 25, 15}};
//Call the method matrixAdd()
int res[][]=matrixAdd(a, b);
//For loop to print the array
for(int i=0; i<a.length; i++) {
for(int j=0;j<b.length;j++)
{
System.out.print(" "+res[i][j]);
}
}
}
//Definition of method matrixAdd
public static int[][] matrixAdd(int[][] a, int[][] b)
{
//Declare the required variables
int rows = a.length;
int cols = 0;
//Check whether the rows is greater than 0
if (rows > 0)
{
//Get the length of array
cols = a[0]...

Want to see the full answer?
Check out a sample textbook solution
Chapter 7 Solutions
Building Java Programs: A Back To Basics Approach (5th Edition)
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





