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

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

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

6条回答
  •  甜味超标
    2020-12-18 00:30

    Having arrays be objects means that you can do operations with them (e.g., someArray.count('foo')) instead of just doing it against them (e.g., count(someArray, 'foo')), which leads to more natural syntax.

提交回复
热议问题