title: Java: check if string contains more than one character
body: <p>I would like to check my inputted string on a comma, which is pretty easy ( just used this: <a href="https://stackoverflow.com/questions/506105/how-can-i-check-if-a-single-character-appears-in-a-string">How can I check if a single character appears in a string?</a>). Now I want to check if a character is present more than once. (in this case a comma (/u002C)) I have created this code:</p>
  
  <pre><code>public static void addTextLimiterDouble(final TextField tf, final int maxLength, final Button submitButton) {
      tf.textProperty().addListener(new ChangeListener&lt;String&gt;() {
          @Override
          public void changed(final ObservableValue&lt;? extends String&gt; ov, final String oldValue, final String newValue) {
  
              if (oldValue.contains("\u002C") &amp;&amp; newValue.endsWith("\u002C")) {
                  tf.setText(oldValue);
              }
      }
  });
  </code></pre>
  
  <p>This gives a StackOverflow error, because it seems it can not get out of the loop. Can anyone explain why it can't?</p>
  
  <p>Note: I know there are maybe more ways to check for more than one character, but I am just curious why this gives me an error.</p>
  
  <p>Any help is greatly appreciated!</p>