title: Resource leak: 'sc' is never closed
body: <p>Program to count how many times a particular character, letter or number occur in a sentence. </p>
  
  <p>However I keep getting message: </p>
  
  <blockquote>
    <p>Resource leak: 'sc' is never closed</p>
  </blockquote>
  
  <p>I am using Java and Eclipse. What should I do?</p>
  
  <pre class="lang-java prettyprint-override"><code>import java.util.Scanner;
  class Number-count {
      public static void number - count(String args[]) {
          String s;
          char ch;
          int count = 0;
          Scanner SC = new Scanner(System. in );
          System.out.println("Enter a sentence");
          String str = sc.nextLine();
          System.out.println("Enter a character to be searched for occurence");
          s = sc.nextLine();
          char c = s.charAt(0);
          for (int i = 0; i &lt; str.length(); i++) {
              ch = str.charAt(i);
              if (ch == c) {
                  count++;
              }
          }
          System.out.println("Character " + c + " occur " + count + " times");
      }
  }
  </code></pre>