title: Java Compare single char to char array
body: <p>I need to compare single char to char array and see if array has that char.</p>
  
  <p>My current code looks like this: </p>
  
  <pre><code>public boolean isThereChar(char[] chaArray, String chr){
      boolean bool = false;
      for(int i=0; i &lt; chaArray.length; i++)
              {
                  if(chr.equals(chaArray[i])){
                      bool = true;
                  }
              }
              return bool;
  }
  </code></pre>
  
  <p><strong>Edit Notes:</strong></p>
  
  <p>Really sorry for being confusing! I am just a Java Beginner =/<br>
  Basically I am writing small Hangman game with GUI.<br>
  My program reads off text file and randomly chooses word which player has to guess, then prints it out in hidden manner like this: _ _ _ _ _ <br>
  In this case I want player to input character or string (person can guess either whole word or just one letter)<br>
  Then I want my program to take that letter or string and compare to my hidden word<br></p>
  
  <p>Following code chooses word and hides it: </p>
  
  <pre><code>public String pickWord(){
      String guessWord = (wordsList[new Random().nextInt(wordsList.length)]);
      return guessWord.toLowerCase();
  }
  
  //Hides picked word
  public char[] setWord(){
      char[] word = new char[pickWord().length() * 2];
      for (int i = 0; i &lt; word.length; i+=2) {
          word[i] = '_';
          word[i + 1] = ' ';
      }
      return word;
  }
  </code></pre>
  
  <p>Then person input his character which he guesses to program with following code: </p>
  
  <pre><code>public void actionPerformed(ActionEvent e) {
      String action = e.getActionCommand();
  
      if (action == "Guess Letter"){
          inputChar = JOptionPane.showInputDialog("Please enter letter (a-z)");
          if (inputChar.length() &gt; 1){
              GuessedLetters glr = new GuessedLetters(inputChar);
              glr.setInString(inputChar);
              //For testing purposes
              System.out.println("This is String: " +glr.getInString());              
          }else{
          GuessedLetters glr = new GuessedLetters(inputChar);
          glr.setInChar(inputChar);
          //For testing purposes
          System.out.println("This is Char: " +glr.getInChar());
          }
      }
  </code></pre>
  
  <p>Lastly I want to take that character which was inputted and compare to my array of chars which is my hidden word: </p>
  
  <pre><code>public boolean isThereChar(char[] array, String str){
      return isThereChar(array, str.charAt(0));
  }
  
  public boolean isThereChar(char[] array, char c){
      for(int i=0; i&lt;array.length; i++){
          if (array[i] == c) return true;
      }
      return false;
  }
  </code></pre>
  
  <p>I want to check what does my code returns (true or false), but I keep failing at doing so.
  (Right now I am trying to call method in my main class to check it, if you can give me tips how to do it otherwise please let me know.)</p>