title: Can a class have both public and private constructor?
body: <p>I came across a scenario, where I need a public and a private constructor. A private constructor is needed to set the private field whose type is a private inner class. 
  Is this encoraged or discouraged ? Else what is a better solution for a scenario listed below ?</p>
  
  <p>Please read the comment, which supports my question more meaningfully. Thanks, </p>
  
  <pre><code>public class CopyTree { 
      private TreeNode root;
  
      public Copytree() { }
  
      //  private CopyTree(TreeNode root) { this.root = root; }
  
      private static class TreeNode {
         TreeNode left;
          TreeNode right;
          Integer element;
          TreeNode(TreeNode left, TreeNode right, Integer element) {
              this.left = left;
              this.right = right;
              this.element = element;
      }
  }
  
  public CopyTree copyTree() {
      CopyTree ct = new CopyTree();
      ct.root = copyTree(root);  // &lt;---- QUESTION:  Any cleaner solution ?? 
      // cleaner solution appears to be a private constructor
      // eg: CopyTree ct = new CopyTree(copyTree(root));  But can public and private constructor     coexist together ?
      return ct;
  }
  
  private TreeNode copyTree(TreeNode binaryTree) {
      TreeNode copy = null;
      if (binaryTree != null) {
          copy = new TreeNode(null, null, binaryTree.element);
          copy.left =  copyTree(binaryTree.left); 
          copy.right = copyTree(binaryTree.right);
      }
      return copy;
  }
  </code></pre>