I'm a little confused about the difference between the getFields
method and the getDeclaredFields
method when using Java reflection.
I read that getDeclaredFields
gives you access to all the fields of the class and that getFields
only returns public fields. If this is the case, why wouldn't you just always use getDeclaredFields
?
Can someone please elaborate on this, and explain the difference between the two methods, and when/why you would want to use one over the other?
question from:https://stackoverflow.com/questions/65598238/getdeclaredfields-returning-nothing