Java, private access in main() : <p>I am studying for the OCA Exam and came across this code:</p>

<pre><code>public class Driver {

  private void printColor(String color) {
    color = "purple";
    System.out.print(color);
  }

  public static void main(String[] args) {
    new Driver().printColor("blue");
  }
}
</code></pre>

<p>The question asks "What is the outcome of this piece of code". I initially thought it will be "it does not compile" because you have an object instance trying to access a private method. But, it turns out to be "purple". </p>

<p>Why is it "purple" and not "it does not compile"? I know the <code>Driver</code> instances lives in the same class it is declared in, but why it still have the privilege to access private methods?</p>

<p>Thank you</p>
