Debugging Java object with Reflection

Oracle Java

When we instantiate new object in Java, sometime we wanna know what is actually that object? Or maybe you wanna know the value of all properties inside? Or the parent of that object?

This is a very basic questions of Java developers in the world. Actually we can use a feature in Java, so called Reflection. If you use this feature to debug Java object, you will know all value of its properties, full class name with package, and so on.

Following code is will help you to debug Java object:

In your unit test or main class, you can call above class as follow:

And this is the output after you run above unit test or main class:

It’s really simple, you also can do it.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*