title: How to create objects from a class with private constructor?
body: <p>I have a class Game that is my main class and a second class Card.
  Class Card hast its properties and constructor private, only function init is public.
  Function init checks values for plausibility and if everything is fine than the constructor gets the values and creates an object.
  Now I wannt in class Game to create an object from class Card.
  How should I do this?</p>
  
  <p>Here is my code:</p>
  
  <p>Class Game:</p>
  
  <pre><code>import java.util.List;
  import java.util.Vector;
  
  
  public class Game {
  
  
  public  static void main(String[] args)
  {
     /*
  CREATING NEW CARD OBJECT
   */
  
      int value = 13;
      Vector&lt;Card&gt; _card_set = new Vector&lt;Card&gt;();
      for (int i = 2; i &lt; 54; i++)
      {
  
          if(--value == 0)
          {
              value = 13;
          }
  
          Card _myCard;
          _myCard.init(i,value);
       }
     }
   }
  </code></pre>
  
  <p>Class Card:</p>
  
  <pre><code>public class Card {
  
  private int index;
  private  int value;
  private String symbol;
  
  /*
  CREATING A PLAYCARD
  */
  
  private Card(int index,int value)
  {
      this.index = index;
      this.value = value;
      value = (int) Math.floor(index % 13);
  
      if(this.index &gt;= 2 &amp;&amp; this.index &lt;= 14)
      {
          this.symbol = "KARO";
      }
      else if (this.index &gt;= 15 &amp;&amp; this.index &lt;= 27)
      {
          this.symbol = "HERZ";
      }
      else if (this.index &gt;= 26 &amp;&amp; this.index &lt;= 40)
      {
          this.symbol = "PIK";
      }
      else if (this.index &gt;= 41 &amp;&amp; this.index &lt;= 53)
      {
  
          this.symbol = "KREUZ";
      }
      System.out.println("Card object wurde erstellt: " + symbol + value);
      System.out.println("------&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;------");
  }
  
  /*
  SHOW FUNCTION
  GET DETAILS ABOUT PLAYCARD
   */
  public String toString()
  {
      return "[Card: index=" + index + ", symbol=" + symbol + ", value=" + value + "]";
  }
  
  /*
  Initialize Card object
   */
  
  public Card init(int index, int value)
  {
      /*
      Check for plausibility
      if correct constructor is called
       */
  
      if((index &gt; 1 || index &gt; 54) &amp;&amp; (value &gt; 0 || value &lt; 14))
      {
         Card myCard = new Card(index,value);
          return  myCard;
      }
      else
      {
          return null;
      }
    }
  }
  </code></pre>