Can I get integer values for a 2D array instead of characters?
<p>I was trying to create the simpliest matrix - 2d array and I have trouble with my code, it is kind of working, but not correctly.
Code:</p>

<pre><code>int result = 0;
    int[][] matrix = new int[2][2];
    for(int rows = 0; rows &lt; matrix.length; rows++)
        for(int cols = 0; cols &lt; matrix[rows].length; cols++)
           matrix[rows][cols] = (rows + cols); 
            System.out.println("matrix is: "+matrix);

    result = matrix[0][0]*matrix[1][1]-matrix[0][1]*matrix[1][0];
    System.out.println("Result is: "+result);
</code></pre>

<p>Output:
matrix is: [[I@1db9742</p>

<p>Result is: -1</p>

<p>I had this one:</p>

<pre><code>int result = 0;
    char[][] matrix= new char[2][2];
    for(int rows = 0; rows &lt; 2; rows++)
        for(int cols = 0; cols &lt; 2; cols++)
           matrix[rows][cols] = (char)('1' + rows * 2 + cols);
    for(int rows = 0; rows &lt; 2; rows++)
        for(int cols = 0; cols &lt; 2; cols++)
            System.out.println("matrix is: "+matrix[rows][cols]);
    result = matrix[0][0]*matrix[1][1]-matrix[0][1]*matrix[1][0];
    System.out.println("Result is: "+result);
</code></pre>

<p>Output:
matrix is: 1</p>

<p>matrix is: 2</p>

<p>matrix is: 3</p>

<p>matrix is: 4</p>

<p>Result is: -2</p>

<p>But I do not want char, I want integer (because what if work with big matrix calculations later) and I do not understand tis part:</p>

<pre><code>('1' + rows * 2 + cols)
</code></pre>

<p>because I copied it from some other code. How to get the first one to work like second and what is that part in brackets (why writen like that)? Thanks in advance!</p>

<p>I got nice stuff with 1 2 3 4 that is what I wanted, but I also need explanation for what that "('1' + rows * 2 + cols)" means. I want to get 1 2 3 4 for matrix 2D array, and then 1*4-2*3 for result. Maybe '1' is to start from 1, not from 0 in loop and write from 1 in array. I found it in some other code, not my solution, first one is mine and not working properly. I added: </p>

<pre><code>for(int cols = 0; cols &lt; matrix[rows].length; cols++)
</code></pre>

<p>as you suggested.</p>

<p>*I rewrote it to english. 
Sorry for language confusion.
I don’t understand why I get characters instead of 2D array when printing matrix after loop, before calculating.</p>