Why ClassName.class.getFields() returns only public fields? <p>I have one class A</p> <pre><code>public class A { String host = "localhost"; public String port = "8078"; protected String preFix = "www."; private String postFix = "/uploads"; } </code></pre> <p>I am getting field details of class A using below code</p> <pre><code>public static void main(String[] args) { Field[] fields = A.class.getFields(); System.out.println("fields are:" + Arrays.toString(fields)); } </code></pre> <p>The output is </p> <pre><code>fields are:[public java.lang.String org.test.A.port] </code></pre> <p>I understand getFields() method returns only those fields which are declared with public access specifier.</p> <p><strong>But why Java implemented getFields() like this?</strong> </p> <p><strong>What is the main intention of Java Team for this kind of implementation?</strong></p>