title: I write this code. But it can't run in finding the first ward
body: <p>I looked it over and can't find out the error. It just can't run the last part of finding the first ward. I think my method of getWard is correct and I can't find where is wrong. Please help!</p>
  
  <pre><code> public static void main(String[] args) {
      Scanner inScanner = new Scanner(System.in);
      String input = getInputString(inScanner);
      int count = getWordCount(input);
      System.out.println("Your string has " + count + " words in it.");
      String first = getWord(input , 1);
      System.out.print("The first word is: " + first);
  
  
  }
      // TODO Auto-generated method stub
  
  private static String getInputString(Scanner inScanner) {
          System.out.println("Enter a string: ");
          String inputString = inScanner.nextLine();
          return inputString;
  }
  private static int getWordCount(String input) {
  
      int count = 1;
  
      for (int i = 0; i &lt; input.length(); i++) {
          if (input.charAt(i) == ' ') {
              count ++;
          }
      }
  
      return count;
  }
  private static String getWord(String input, int n){
      String myString = getWord(input , 1);
      return myString;
  }
  }
  </code></pre>