In Java, why are arrays objects? Are there any specific reasons?

前端 未结 6 2192
半阙折子戏
半阙折子戏 2020-12-17 23:37

Is there any reason why an array in Java is an object?

6条回答
  •  囚心锁ツ
    2020-12-18 00:33

    So that they get all the benefits thereof:

    • getHashCode()
    • toString()

    etc.

    And arrays aren't 'primitive', so if they can't be primitive, they must be objects.

提交回复
热议问题