title: How do I check if a string contains keywords?
body: <p>I'm writing a program that asks the user to enter keywords, and an essay, and then checks how many keywords were used in the essay. </p>
  
  <p>Current output: </p>
  
  <hr>
  
  <p>Enter keywords: </p>
  
  <p>dog, cat</p>
  
  <p>Enter essay: </p>
  
  <p>i like cat</p>
  
  <p>Exception in thread "main" java.lang.RuntimeException</p>
  
  <hr>
  
  <p>Desired output:</p>
  
  <hr>
  
  <p>Enter keywords: </p>
  
  <p>dog, cat</p>
  
  <p>Enter essay: </p>
  
  <p>i like cat</p>
  
  <p>1</p>
  
  <hr>
  
  <p>Here's my code so far: </p>
  
  <pre><code>static int keywordsChecker(String shortEssay, String keywords) {
          int count = 0;
  
          for (int i = 0; i &lt; keywords.length(); i++) {
  
              String[] ary = keywords.split(",");
  
              if (shortEssay.contains(ary)) {
                  count++;
              }
              System.out.println(count);
  
  
          }
           return count;
      }
  
      public static void main(String[] args) {
          Scanner input = new Scanner(System.in);
          System.out.println("Enter keywords: ");
          String keyword = input.nextLine();
          System.out.println("Enter essay: ");
          String essay = input.nextLine();
          keywordsChecker(essay, keyword);
  
      }
  </code></pre>