Is it possible in Java to override 'toString' for an Objects array?

前端 未结 7 601
一整个雨季
一整个雨季 2020-11-28 12:00

Is it possible in Java to override a toString for an Objects array?

For example, let\'s say I created a simple class, User (it doesn\'t really matter wh

7条回答
  •  日久生厌
    2020-11-28 12:55

    You can create a separate class containing the array, and override toString().

    I think the simplest solution is to extend the ArrayList class, and just override toString() (for example, UserArrayList).

提交回复
热议问题