There are many answers on stackoverflow about how to iterate through the declared fields of a class. Can I do this with an object? For example, say I want to iterate through all the fields of an object of MyClass after creation to check which fields are null (I know this is not practical). Is there any way to do this?
Asked
Active
Viewed 56 times
0
-
Hint, every object belongs to a class `o.getClass()`. It's the class that defines what fields the object has. – Solomon Slow Dec 04 '15 at 19:05
-
I see that the question is a duplicate. Does anyone know if this method is thread-safe? – b_pcakes Dec 04 '15 at 20:26