title: Answer consists out of certain characters
body: <pre><code>Scanner input = new Scanner(System.in);
  String[] colors = {"R", "G", "B", "P", "O", "Y"};
  String guess = "";
  String valid = false;
  
  
  //Get Input
  guess = input.nextLine().toUpperCase();
  
  // Change String Array to Regular String
  String Colors = "";
  for(int i=0; i&lt;colors.length; i++) {
      Colors += colors[i];
  }
  
  // See if Guess Consists out of Correct Letters
  if(guess.matches(Colors)) {
      valid = true;
  }
  </code></pre>
  
  <p>Basically what I want to achieve with this code is to check if the input given meets the requirements.
  <br />In this case does <code>guess</code> only consists of the letters given in <code>colors</code>, for example:</p>
  
  <p>if <code>guess = RGB</code> then <code>valid = true</code>
  <br />if <code>guess = RGBA</code> then <code>valid = false</code></p>
  
  <p>I know I can also put it in manually like this:</p>
  
  <pre><code>if(guess.matches("[RGBPOY]+")) {
      valid = true;
  }
  </code></pre>
  
  <p>But I want to keep it procedural.</p>
  
  <p>Is there a way to get this working? Or am I better off using a different method like say a for loop?
  <br />I only recently started with JAVA and am not yet familiar with all the different approaches it has to offer.</p>