title: How do I set a constructor's parameters to an array of variable size?
body: <p>HOMEWORK: We're working on a hangman program. I have the following method: </p>
  
  <pre><code>    public char[] selectWord()
      {
          String[] hangmanWords = new String[50] { "time", "person", "year", "way", "day", "thing", "man", "world", "life", "hand", "part", "child", "eye", "woman", "place", "work", "week", "case", "point", "government", "company", "number", "group", "problem", "fact", "good", "new", "first", "last", "long", "great", "little", "own", "other", "old", "right", "big", "high", "different", "small", "large", "next", "early", "young", "important", "few", "public", "bad", "same", "able" };
          Random wordIndex = new Random();
          int randomIndex = wordIndex.Next(0, 49); 
          wordToGuess = hangmanWords[randomIndex].ToUpper();
          char[] wordToGuessArray = wordToGuess.ToCharArray();                                         // convert word to array of letters
          return wordToGuessArray;  
      }
  </code></pre>
  
  <p>I would like to define a constructor for <code>wordToGuessArray</code>. Ideally I want the <code>selectWord()</code> method to set the <code>wordToGuessArray</code> parameter. However, I won't know the variable array length until after I run this method and I can't create a constructor without explicitly defining <code>char[x]</code>. <a href="https://stackoverflow.com/questions/8918660/constructor-for-array-of-variable-size">This question</a> has the array length set in main. Mine cannot due to requirements restrictions in the assignment. So where would this <code>selectWord()</code> method need to live in order to properly <code>set</code> my variable? </p>
  
  <p>I'm having a hard time picturing a workable program flow for that. </p>