title: Java - How do i make a string read and count amounts in another string (
body: <p>I'm having trouble activating my counter++. So far s2 is able to read s1, but cannot count amount of occurrences. Any help would be appreciated. (I realize that I am working in the wrong string, but it helps me to create the solution here first and then send it to a second string, is this poor logic?) </p>
  
  <p>Sorry for the dumb question I am very new at programming</p>
  
  <p>//i need a scanner that reads what i write that scanner should count
  occurrences of a char another scanner declared scanner a would ask " write something" string s. = nextline etc new scanner asks for a letter string s1 = next line blb that input = something int count = StringUtils.countMatches(s1); System.out.print(amount ) i
  //</p>
  
  <pre><code>public class Task07 {
  
      public static void main(String[] args) {
  
          Scanner s1 = new Scanner(System.in);
          System.out.println("write something");
          String text = s1.nextLine(); //reads user input value
  
          Scanner s2 = new Scanner(System.in);  // missing smth that limits length of s2  
          System.out.println("geb a letter");
          String letter = s2.nextLine();
          int counter = 0;
          boolean found;
          found = text.contains(letter);
          if (found == true) {
              counter++;
          } else {
  
              System.out.println(counter);
          }
      // could use counter from 6 here but need a way to tell counter 
          // that it should add +1 for every time something occurs in 
          // the other scanner
  
          /*
              Problems: text recognizer is boolean only
               - doesnt activate counter
               - doesnt activate counter based on X times occurence           
              - doesnt limit "letter" to only one char
              - 
  
           */
      }
  
  }
  </code></pre>