title: What is the difference between getFields and getDeclaredFields in Java reflection
body: <p>I'm a little confused about the difference between the <code>getFields</code> method and the <code>getDeclaredFields</code> method when using Java reflection. </p>
  
  <p>I read that <code>getDeclaredFields</code> gives you access to all the fields of the class and that  <code>getFields</code> only returns public fields. If this is the case, why wouldn't you just always use <code>getDeclaredFields</code>? </p>
  
  <p>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? </p>