title: Java: Count occurrences of characters in text file
body: <p>This is part of a program that will count the occurrences of each letter within the text file. I want it to print something like A:4 B:23 C:32 and instead it prints A:0B:0C:0A:0B:0C:0A:0B:0C:0 which does not even find all of the occurrences of each letter. What am I doing wrong here? Thanks for the help!!</p>
  
  <pre><code>             char ch = line.charAt(0);
  
                  int Acounter=0;
                  int Bcounter=0;
                  int Ccounter=0;
                  switch (ch)
                  {
                      case 'A':
                         Acounter++;
                          break;
                      case 'B':
                          Bcounter++;
                          break;
                      case 'C':
                          Ccounter++;
                          break;
                  }
  
               bw.write ("A:" + Acounter);
               bw.write ("B:" + Bcounter);
               bw.write ("C:" + Ccounter);
  </code></pre>