title: Can we have a return type for a constructor in Java?
body: <p>The following code gives a compilation error:</p>
  
  <pre><code>class parent {
    parent(int a){}
  }
  
  class child extends parent{}
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Main.java:6: cannot find symbol
  symbol  : constructor parent()
  location: class parent
  class child extends parent{}
  ^
  1 error
  </code></pre>
  
  <p>I was trying to do different things and found that adding a return type to the parent constructor got rid of the error!!!</p>
  
  <pre><code>class parent {
    int parent(int a){}
  }
  
  class child extends parent{}
  </code></pre>
  
  <p>I've read that constructors should not have return type, which clearly is not correct all the times. So my question is when should we have return type for constructor?</p>