title: How to count ";" in line
body: <p>I want to count ";" in line from text file.</p>
  
  <p>Ex. In my text file</p>
  
  <ul>
  <li>case 1: int a; int b;</li>
  <li>case 2: int c;</li>
  <li>case 3: int x; int y; int z;</li>
  </ul>
  
  <p>My expected out put is</p>
  
  <ul>
  <li>line 1 have 2 ";" in line</li>
  <li>line 2 have 1 ";" in line</li>
  <li>line 3 have 3 ";" in line</li>
  </ul>
  
  <p>My code</p>
  
  <pre><code>Scanner (input);
  
  while(in.hasNext()){
  
              String line = in.nextLine();
              in.hasNextLine();
              LOC++;
              if (line.length() &gt;0){
                  k = -1;
  
                  if(line.indexOf(";") != 1){
                      while(true){
                          k = line.indexOf(";");
                          if(k&lt;0)break;
                          cCommand++;
                      }
  
                  }
  
              }
          }
  
  System.out.println(output);
  </code></pre>
  
  <p><strong>Thank you for your answering.</strong></p>