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 which class is it since this is a general question). Is it possible that, once the client creates a User[]
array and the client uses System.out.print(array)
, it won't print the array's address but instead a customized toString()
?
PS: of course I can't just override toString()
in my class since it's related to single instances.
No. Of course you can create a static method User.toString( User[] ), but it won't be called implicitly.