I have the following class:
public class Test {
public static int a = 0;
public int b = 1;
}
Is it possible to use reflection to get a list of the static fields only? I'm aware I can get an array of all the fields with Test.class.getDeclaredFields()
. But it seems there's no way to determine if a Field
instance represents a static field or not.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…