Trying to get my matrix printed not the heap address

前端 未结 1 873
生来不讨喜
生来不讨喜 2021-01-29 08:42

The code seems to run except what I am getting is not a matrix of a specified (by the user) size but what I think is a heap address Here\'s what it returns when the user inputs

1条回答
  •  孤独总比滥情好
    2021-01-29 09:22

    Java arrays do not override toString() so you are getting the default implementation from Object. Instead, you can use Arrays.deepToString(Object[]) like

    System.out.println("The row-sort matrix is..." + Arrays.deepToString(m));
    

    0 讨论(0)
提交回复
热议问题