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

A string headded by "+" causes NumberFormatException

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      Exception occurs with such string on :
         Integer.valueOf
         Long.ValueOf
         Short.ValueOf

      No problem:
         Double.valueOf
         Float.valueOf
       
       
      Sample program:

      public class test2{
         public static void main(String aa[]){
            Double doubleValue;
            Float floatValue;
            Integer integerValue;
            Long longValue;
            Short shortValue;
            doubleValue = Double.valueOf("+3.21"); // OK
            floatValue = Float.valueOf("+3.21"); // OK
            integerValue = Integer.valueOf("+321"); // NumberFormatException
            longValue = Long.valueOf("+321"); // NumberFormatException
            shortValue = Short.valueOf("+321"); // NumberFormatException
         }
      }

        Attachments

          Activity

            People

            Assignee:
            tlindholsunw Timothy Lindholm (Inactive)
            Reporter:
            sishidasunw Shoji Ishida (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: