title: ''s cannot be resolved'' How can i solve this error?
body: <p>I am a beginner with a weak understanding of Java. I use Dr.Java and I get this error:</p>
  
  <pre><code>     "S cannot be resolved"
  </code></pre>
  
  <p>With this Java program:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class HDtest5
  
  {
      public static int countWords(String str) {
          String words[] = str.split(" ");
          int count = words.length;
          return count;
      }
  
      public static void main(String[] args) {
          Scanner in = new Scanner(System.in);
          System.out.print("Enter a sentence: ");
          String sentence = in.nextLine();
          System.out.print("Your sentence has " + countWords(sentence) + " words.");
      }
  
      {
          while (true) // have created infinite loop
          {
  
              if (s.equals("quit"))
              // if enterd value is "quit" than it comes out of loop
  
              {
  
                  String[] words = s.split(" "); // get the individual words
                  System.out.println("#words = " + words.length);
                  for (int i = 0; i &lt; words.length; i++)
                      System.out.println(s + "word[" + i + words[i] + " nchars = " + words[i].length());
  
              }
              System.out.println(s); // to Print string
              System.out.println(s.length()); // to print Entered string's length
  
          }
      }
  }
  </code></pre>
  
  <p>What causes this error message? 
  I thought all the strings called 's' should work together without any problems. Could you please help me to find out what is wrong with it? Thank you very much for any help, its much appreciated!</p>
  
  <p>Ps. Just to be more clear, the purpose of my program is to output total number of characters, characters of each word and a number of words of the text entered in text window (scanner). The code should work perfectly, except this 's' string problem which makes the chunks of code not work together. </p>