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

前端 未结 7 593
一整个雨季
一整个雨季 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:33

    Try this

    User[] array = new User[2];
    System.out.println(Arrays.asList(array));
    

    of course if you have customized user.toString() method

提交回复
热议问题