Suma de dos matrices - Me devuelve "[[D@7d4991ad"
Publicado por Jorge (6 intervenciones) el 31/03/2019 21:05:08
Hice un intento de programa para sumar dos matrices (soy novato en java) , el problema es que el resultado me devuelve un "[[D@7d4991ad" y no se como podria solucionarlo. cualquier ayuda es bienvenida.
MAIN:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package bidimensional;
import java.util.Scanner;
public class Bidimensional {
private double[][] matriz;
private int renglones;
private int columnas;
public Bidimensional(int renglones, int columnas) { // constructor y pido el ingreso de valores a matrices
Scanner entrada = new Scanner(System.in);
this.matriz = new double [renglones][columnas];
for(int i=0 ; i<renglones; i++)
{
for(int j=0; j<columnas; j++) {
System.out.print("Ingresar el numero de matriz ["+i+":"+j+"]: ");
matriz[i][j]=entrada.nextDouble();
}
}
}
public double[][] suma(Bidimensional m2) // operacion de suma
{
for(int i=0; i<2; i++) {
for(int j=0; j<2; j++)
{
matriz[i][j]=matriz[i][j]+m2.matriz[i][j];
}
}
return matriz;
}
}
MAIN:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package testBidimensional;
import bidimensional.Bidimensional;
public class TestBidimensional {
public static void main(String[] args) {
// TODO Auto-generated method stub
Bidimensional matrices1 = new Bidimensional(2,2);
Bidimensional matrices2 = new Bidimensional(2,2);
System.out.println("Suma: "+matrices1.suma(matrices2));
}
}
Valora esta pregunta


0