Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4015336

Method Double.valueOf(String s) doesnot throw NumberformatException for DigitStr

XMLWordPrintable

    • sparc
    • solaris_2.4

      Method Double.valueOf(String s) where s should be string representation of floating-point value Floating value is described in spec is as follows

      [Sign] Digits . [Digits] [ExponentPart] or
              [Sign] . Digits [ExponentPart]

      Check out attached TestDouble.java should thow NumberFormatException.

      ---------------------8<--------------- TestDouble.java -----------------------
      public class TestDouble {
        
        public static void main(String[] argv) {
          try {
             
            Double d = Double.valueOf("0");
            System.out.println("Failed Result:" + d.toString());
            d = Double.valueOf("1234");
            System.out.println("Failed Result:" + d.toString());
          }
          catch (Exception e) {
            System.out.println(e);
          }
        }
      }

            gbrachasunw Gilad Bracha (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: