Java String Parse tryParse(String s, double d)

Here you can find the source of tryParse(String s, double d)

Description

try Parse

License

Creative Commons License

Declaration

public static double tryParse(String s, double d) 

Method Source Code

//package com.java2s;
// The license under which this software is released can be accessed at:

public class Main {
    public static int tryParse(String s, int i) {
        try {/*from w  ww  .  j a  v  a2  s . c  o m*/
            return Integer.parseInt(s);
        } catch (Exception e) {
            return i;
        }
    }

    public static double tryParse(String s, double d) {
        try {
            return Double.parseDouble(s);
        } catch (Exception e) {
            return d;
        }
    }
}

Related

  1. tryParse(String input, Object defVal)
  2. tryParse(String pValue)
  3. tryParse(String s, int i)
  4. tryParse(String s, Integer defaultValue)
  5. tryParse(String val, int defaultValue)
  6. tryParseToType(Object object, Class clazz)