[ S O L V E D ] - How to check if a string is a double safely in JAVA

String str = "1234.0123";
        try
        {
            Double dbl;
            dbl = Double.parseDouble(str);
            System.out.println("its a double");
         
        }
        catch(java.lang.NumberFormatException cce)
        {
        }

No comments:

Post a Comment

2 ads