< prev index next >

test/jdk/java/lang/Float/ParseFloat.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

@@ -274,28 +274,25 @@
       * proper value; just whether the input is accepted appropriately
       * or not.
       */
      private static void testParsing(String [] input,
                                      boolean exceptionalInput) {
-         for(int i = 0; i < input.length; i++) {
-             double d;
- 
+         for (String s : input) {
              try {
-                 d = Float.parseFloat(input[i]);
-                 check(input[i]);
-             }
-             catch (NumberFormatException e) {
-                 if (! exceptionalInput) {
+                 Float.parseFloat(s);
+                 check(s);
+             } catch (NumberFormatException e) {
+                 if (!exceptionalInput) {
                      throw new RuntimeException("Float.parseFloat rejected " +
-                                                "good string `" + input[i] +
+                                                "good string `" + s +
                                                 "'.");
                  }
-                 break;
+                 continue;
              }
              if (exceptionalInput) {
                  throw new RuntimeException("Float.parseFloat accepted " +
-                                            "bad string `" + input[i] +
+                                            "bad string `" + s +
                                             "'.");
              }
          }
      }
  
< prev index next >