I have an Java bean class Person containing 3 variables:
- name (String)
- age (String)
- address (Object).
Address contains 3 variables:
- street
- door_no
- city
I would like to have a utility which should print all variables in Person.
By this I mean it should print Person & also the Address object contained in it.
I could create a hashmap and put the variable names & values using reflection and print key/value UI in JSP but the issue is I have to apply reflection for Address to add variable/value in the hashmap.
Is there a utility available to do this?
You could use ToStringBuilder from Apache Commons.
From documentation:
More details: