I have a Java class that has a number of Fields
.
I would like to Loop over al lthe fields and do something for the one's that are null.
For example if my class is:
public class ClassWithStuff {
public int inty;
public stringy;
public Stuff;
//many more fields
}
In another location, I'd make a ClassWithStuff
object and I would like to go though all the fields in the class. Kind of like this:
for (int i = 0; i < ClassWithStuff.getFields().size(); i++) {
//do stuff with each one
}
Is there any way for me to achieve this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…