Generic Object toString method using reflections in Java

You may also like...

Subscribe
Notify of
guest
2 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Dev Parker
Dev Parker
August 4, 2016 23:54

Interesting alternative to the commons-lang3 technique; viz
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
….
Using commons-lang3 rel 3.3.2
yields
com.fcrllc.decorator.Vehicle@29453f44[engine=default,color=black]
com.fcrllc.decorator.Car@61bbe9ba[wheels=4,engine=default,color=black]

computer scientist
computer scientist
April 10, 2023 13:38

interesting.

2
0
Would love your thoughts, please comment.x
()
x