I have a lot of data objects, and I want to be able to generate a String representing each object, without implementing a toString method for each one.
I’m thinking of reflection for getting the fields and its values.
any other ideas?
thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You are welcome to use ToStringBuilder from jakarta. It has 2 modes one requires adding all fields you need using API, other is reflection based: