Click here to Skip to main content
15,867,686 members

Java Printing int array returns gibberish?

darkknight2012 asked:

Open original thread
Could someone let me know why my code will not print an int array, instead it prints a string such as [[I@1d256a73

Java
public class ArrayMultiplication {
	public static void main (String args []){
	int [][]a={{1,6,2},{4,18,3},{5,8,4}};
	int [][]b= {{9,12,13},{6,9,7},{32,4,3}};
	int [][]product = multiply (a,b);
	System.out.println (""+product);
	}
	public static int [][] multiply (int [][]a, int[][]b){
		int aRows=a.length;
		int aColumns=a[0].length;
		int bRows=b.length;
		int bColumns=b[0].length;
		if (aRows != aColumns || bRows != bColumns) {
			return null; 
		}
		int[][]resultantProduct = new int [aRows][aColumns];
		for (int i=0; i<aRows; i++) {
			for (int h=0; h<aColumns; h++) {
				resultantProduct [i][h] += a[i][h] * b[i][h];
			}
		}
		return resultantProduct;
	}
}
Tags: Javascript, Java

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900