title: Java: Including spaces when finding the length of the string
body: <pre><code>Scanner input = new Scanner(System.in); 
  Scanner input2 = new Scanner(System.in);
  
  System.out.println("Please enter a string: ");
  String a = input.next();
  
  System.out.println("Please enter another string: ");
  String b = input2.next();
  
  int s1 = a.length();
  int s2 = b.length();
  int i;
  
  if(a.equalsIgnoreCase(b)){
     System.out.println(a.substring(i = 0, i + s2));
  }
  </code></pre>
  
  <p>I'm trying to compare 2 strings that are input by the user. The string comparison is working fine, however, when I input a string with spaces like
  "i like dogs," it counts the string length as 1 instead of 11 because of the space between "i" and "like." Why is the program not counting the spaces or the remaining characters after the first space?</p>