title: Class with private construct instantiated outside class
body: <p>I found this code online where the person is instantiating a class which has a private constructor outside the class. I am not able to understand how this works, cause from what I had read earlier, you use a private constructor in a class so that it cannot be instantiated outside the class.</p>
  
  <pre><code>public final class A extends B {
    private A(Something, Something)
    {
      //Something
    }
  
    public void someMethods()
    {
      //Something
    }
  }
  
  public final class B {
    private A a;
    public void someMethod()
    {
      final ObjectInputStream objectInputStream = new ObjectInputStream(
                              new ByteArrayInputStream(buffer.toByteArray()));
      a = (A) objectInputStream.readObject();
      objectInputStream.close();
  
      a.someMethods();
    }
  } 
  </code></pre>
  
  <p>I just want to understand what exactly is going on here? I tried reading up on <code>ObjectInputStream</code> but could not get anything out of it.</p>