Coming from JavaScript
, I find it surprisingly hard to do so. In JS
it was as easy as writing object's name in console. One way is to override toString()
. But it is too tedious since I have to print all the instance variable separately? Am I right? If yes, is there another way?
Asked
Active
Viewed 529 times
0

dasfdsa
- 7,102
- 8
- 51
- 93
-
toString though is the best way. But since you have to print all the instance variables separately (not sure why) you can use their getter methods. – Himanshu Bhardwaj Nov 21 '16 at 08:39
-
You can use Lombok for this as described in [my answer](http://stackoverflow.com/a/40716165/1997376) – Nicolas Filotto Nov 21 '16 at 09:04
1 Answers
0
Yes you right, but you can use some tools for override toString
method easily, for example ToStringBuilder
method reflectionToString

Aleksandr Podkutin
- 2,532
- 1
- 20
- 31