小编W M*_*W M的帖子

如何正确地将对象显示为String

我正在研究这个代码,并希望打印一个矩阵,但那就是出现了什么 Matrix@2c78bc3b Matrix@2a8ddc4c

这是一个代码示例:

public class Matrix
{

    public static int rows;
    public static int colms;//columns
    public static int[][] numbers;

    public Matrix(int[][] numbers)
    {

        numbers = new int[rows][colms];

    }


    public static boolean isSquareMatrix(Matrix m)
    {
        //rows = numbers.length;
        //colms = numbers[0].length;

        if(rows == colms)
           return true;
        else
            return false;
    }

    public static Matrix getTranspose(Matrix trans)
    {
       trans = new Matrix(numbers);

        for(int i =0; i < rows; i++)
        {
            for(int j = 0; j < colms; j++)
            {
                trans.numbers[i][j] = numbers[j][i]; …
Run Code Online (Sandbox Code Playgroud)

java tostring

4
推荐指数
1
解决办法
198
查看次数

2
推荐指数
1
解决办法
8474
查看次数

生成数组的随机索引

我知道这对于正常的整数,但是对于像指数这样的东西吗?

Random dice = new Random();
int n = dice.nextInt(6);
System.out.println(n);
Run Code Online (Sandbox Code Playgroud)

java

0
推荐指数
2
解决办法
2万
查看次数

标签 统计

java ×3

tostring ×1