safe Parse Double - Java java.lang

Java examples for java.lang:String Parse

Description

safe Parse Double

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        String toParse = "java2s.com";
        System.out.println(safeParseDouble(toParse));
    }//from  w w  w .  ja va2s .  co  m

    public static Double safeParseDouble(String toParse) {
        try {
            return Double.valueOf(toParse);
        } catch (NumberFormatException e) {
            return null;
        }
    }
}

Related Tutorials