title: Weird behaviour with Scanner#nextFloat
body: <p>Running the following in Eclipse initially caused Scanner to not recognize carriage returns in the console effectively blocking further input:</p>
  
  <pre><code>price = sc.nextFloat();
  </code></pre>
  
  <p>Adding this line before the code causes Scanner to accept 0,23 (french notation) as a float:</p>
  
  <pre><code>Locale.setDefault(Locale.US);
  </code></pre>
  
  <p>This is most probably due to regional settings in Windows XP Pro (French/Belgian). When the code is run again 0,23 is still accepted and entering 0.23 causes it to throw a <code>java.util.InputMismatchException</code>.</p>
  
  <p>Any explanation as to why this is happening? Also is there a workaround or should I just use <code>Float#parseFloat</code>?</p>
  
  <p>Edit: This demonstrates how Scanner behaves with different Locales (uncomment one of the lines at the beginning).</p>
  
  <pre><code>import java.util.Locale;
  import java.util.Scanner;
  
  
  public class NexFloatTest {
  
      public static void main(String[] args) {
  
          //Locale.setDefault(Locale.US);
          //Locale.setDefault(Locale.FRANCE);
  
          // Gives fr_BE on this system
          System.out.println(Locale.getDefault());
  
          float price;
  
          String uSDecimal = "0.23";
          String frenchDecimal = "0,23";
  
          Scanner sc = new Scanner(uSDecimal);
  
          try{
              price = sc.nextFloat();
              System.out.println(price);
          } catch (java.util.InputMismatchException e){
              e.printStackTrace();
          }
  
          try{
              sc = new Scanner(frenchDecimal);
              price = sc.nextFloat();
              System.out.println(price);
          } catch (java.util.InputMismatchException e){
              e.printStackTrace();
          }
  
          System.out.println("Switching Scanner to System.in");
  
          try{
              sc = new Scanner(System.in);
              System.out.println("Enter a float value");
              price = sc.nextFloat();
              System.out.println(price);
          } catch (java.util.InputMismatchException e){
              e.printStackTrace();
          }
  
          System.out.print("Enter title:");
  
          String title = sc.nextLine(); // This line is skipped
  
          System.out.print(title);
      }
  
  }
  </code></pre>
  
  <p>Edit: This reproduces the issue where the Scanner is waiting for a float value but fails to trigger when you press return:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class IgnoreCRTest {
  
      public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          System.out.println("Enter a float value:");
          // On french Locale use , as the decimal separator
          float testFloat = sc.nextFloat();
          System.out.println(testFloat);
          //sc.skip("\n"); // This doesn't solve the issue
          sc.nextLine();
          System.out.println("Enter an integer value:");
          int testInt = sc.nextInt();
          System.out.println(testInt);
          // Will either block or skip here
          System.out.println("Enter a string value :");
          String testString = sc.nextLine();
          System.out.println(testString);
      }
  
  }
  </code></pre>